1 29 30 package nextapp.echo2.app.util; 31 32 import java.util.ArrayList ; 33 34 40 public class ResizingArrayList extends ArrayList { 41 42 45 public void add(int i, Object o) { 46 while (i > size()) { 47 super.add(null); 48 } 49 super.add(i, o); 50 } 51 52 55 public Object remove(int i) { 56 Object o = super.remove(i); 57 while (size() > 0 && get(size() - 1) == null) { 58 super.remove(size() - 1); 59 } 60 return o; 61 } 62 63 66 public boolean remove(Object o) { 67 if (super.remove(o)) { 68 while (size() > 0 && get(size() - 1) == null) { 69 super.remove(size() - 1); 70 } 71 return true; 72 } else { 73 return false; 74 } 75 } 76 77 80 public Object set(int i, Object o) { 81 while (i >= size()) { 82 super.add(null); 83 } 84 return super.set(i, o); 85 } 86 } 87 | Popular Tags |