FileDocCategorySizeDatePackage
IndexedVector.javaAPI DocGlassfish v2 API1980Wed Aug 30 15:34:14 BST 2006persistence.antlr.collections.impl

IndexedVector

public class IndexedVector extends Object
A simple indexed vector: a normal vector except that you must specify a key when adding an element. This allows fast lookup and allows the order of specification to be preserved.

Fields Summary
protected Vector
elements
protected Hashtable
index
Constructors Summary
public IndexedVector()
IndexedVector constructor comment.

        elements = new Vector(10);
        index = new Hashtable(10);
    
public IndexedVector(int size)
IndexedVector constructor comment.

param
size int

        elements = new Vector(size);
        index = new Hashtable(size);
    
Methods Summary
public synchronized voidappendElement(java.lang.Object key, java.lang.Object value)

        elements.appendElement(value);
        index.put(key, value);
    
public java.lang.ObjectelementAt(int i)
Returns the element at the specified index.

param
index the index of the desired element
exception
ArrayIndexOutOfBoundsException If an invalid index was given.

        return elements.elementAt(i);
    
public java.util.Enumerationelements()

        return elements.elements();
    
public java.lang.ObjectgetElement(java.lang.Object key)

        Object o = index.get(key);
        return o;
    
public synchronized booleanremoveElement(java.lang.Object key)
remove element referred to by key NOT value; return false if not found.

        Object value = index.get(key);
        if (value == null) {
            return false;
        }
        index.remove(key);
        elements.removeElement(value);
        return false;
    
public intsize()

        return elements.size();