1 package antlr.collections.impl; 2 3 9 10 import java.util.Hashtable ; 11 import java.util.Enumeration ; 12 13 import antlr.collections.impl.Vector; 14 15 20 public class IndexedVector { 21 protected Vector elements; 22 protected Hashtable index; 23 24 25 28 public IndexedVector() { 29 elements = new Vector(10); 30 index = new Hashtable (10); 31 } 32 33 37 public IndexedVector(int size) { 38 elements = new Vector(size); 39 index = new Hashtable (size); 40 } 41 42 public synchronized void appendElement(Object key, Object value) { 43 elements.appendElement(value); 44 index.put(key, value); 45 } 46 47 53 public Object elementAt(int i) { 54 return elements.elementAt(i); 55 } 56 57 public Enumeration elements() { 58 return elements.elements(); 59 } 60 61 public Object getElement(Object key) { 62 Object o = index.get(key); 63 return o; 64 } 65 66 67 public synchronized boolean removeElement(Object key) { 68 Object value = index.get(key); 69 if (value == null) { 70 return false; 71 } 72 index.remove(key); 73 elements.removeElement(value); 74 return false; 75 } 76 77 public int size() { 78 return elements.size(); 79 } 80 } 81 | Popular Tags |