Package org.antlr.v4.runtime.misc
Class OrderedHashSet<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- java.util.HashSet<E>
-
- java.util.LinkedHashSet<T>
-
- org.antlr.v4.runtime.misc.OrderedHashSet<T>
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<T>
,Collection<T>
,Set<T>
public class OrderedHashSet<T> extends LinkedHashSet<T>
A 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 LinkedHashSet.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description OrderedHashSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T value)
Add a value to list; keep in hashtable for consistency also; Key is object itself.void
clear()
Object
clone()
List<T>
elements()
Return the List holding list of table elements.boolean
equals(Object o)
T
get(int i)
int
hashCode()
Iterator<T>
iterator()
boolean
remove(int i)
boolean
remove(Object o)
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.Object[]
toArray()
String
toString()
-
Methods inherited from class java.util.LinkedHashSet
spliterator
-
Methods inherited from class java.util.AbstractSet
removeAll
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
-
-
-
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.
-
remove
public boolean remove(int i)
-
add
public boolean add(T 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(Object o)
-
clear
public void clear()
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<T>
- Specified by:
hashCode
in interfaceSet<T>
- Overrides:
hashCode
in classAbstractSet<T>
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceCollection<T>
- Specified by:
equals
in interfaceSet<T>
- Overrides:
equals
in classAbstractSet<T>
-
elements
public 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.
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<T>
- Specified by:
toArray
in interfaceSet<T>
- Overrides:
toArray
in classAbstractCollection<T>
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection<T>
-
-