Package org.antlr.misc
Class OrderedHashSet<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- java.util.HashSet
-
- org.antlr.misc.OrderedHashSet<T>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable,java.util.Collection,java.util.Set
public class OrderedHashSet<T> extends java.util.HashSetA HashMap that remembers the order that the elements were added. You can alter the ith element with set(i,value) too :) Unique list. I need the replace/set-element-i functionality so I'm subclassing OrderedHashSet.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description OrderedHashSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(java.lang.Object value)Add a value to list; keep in hashtable for consistency also; Key is object itself.voidclear()java.util.List<T>elements()Return the List holding list of table elements.Tget(int i)booleanremove(java.lang.Object o)Tset(int i, T value)Replace an existing value with a new value; updates the element list and the hash table, but not the key as that has not changed.intsize()java.lang.StringtoString()-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray
-
-
-
-
Field Detail
-
elements
protected java.util.List<T> elements
Track the elements as they are added to the set
-
-
Method Detail
-
get
public T get(int i)
-
set
public T set(int i, T value)
Replace an existing value with a new value; updates the element list and the hash table, but not the key as that has not changed.
-
add
public boolean add(java.lang.Object value)
Add a value to list; keep in hashtable for consistency also; Key is object itself. Good for say asking if a certain string is in a list of strings.
-
remove
public boolean remove(java.lang.Object o)
-
clear
public void clear()
-
elements
public java.util.List<T> elements()
Return the List holding list of table elements. Note that you are NOT getting a copy so don't write to the list.
-
size
public int size()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.util.AbstractCollection
-
-