1 15 16 package javassist.bytecode; 17 18 final class LongVector { 19 static final int SIZE = 128; 20 private int num; 21 private Object [] objects; 22 private LongVector next; 23 24 public LongVector() { 25 this(SIZE); 26 } 27 28 public LongVector(int initialSize) { 29 num = 0; 30 objects = new Object [initialSize]; 31 next = null; 32 } 33 34 public void addElement(Object obj) { 35 LongVector p = this; 36 while (p.next != null) 37 p = p.next; 38 39 if (p.num < p.objects.length) 40 p.objects[p.num++] = obj; 41 else { 42 LongVector q = p.next = new LongVector(SIZE); 43 q.objects[q.num++] = obj; 44 } 45 } 46 47 public int size() { 48 LongVector p = this; 49 int s = 0; 50 while (p != null) { 51 s += p.num; 52 p = p.next; 53 } 54 55 return s; 56 } 57 58 public Object elementAt(int i) { 59 LongVector p = this; 60 while (p != null) 61 if (i < p.num) 62 return p.objects[i]; 63 else { 64 i -= p.num; 65 p = p.next; 66 } 67 68 return null; 69 } 70 71 85 } 86 | Popular Tags |