Package org.antlr.v4.runtime.misc
Class OrderedHashSet<T>
java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractSet<T>
java.util.HashSet<T>
java.util.LinkedHashSet<T>
org.antlr.v4.runtime.misc.OrderedHashSet<T>
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<T>
,Collection<T>
,SequencedCollection<T>
,SequencedSet<T>
,Set<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:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add a value to list; keep in hashtable for consistency also; Key is object itself.void
clear()
clone()
elements()
Return the List holding list of table elements.boolean
get
(int i) int
hashCode()
iterator()
boolean
remove
(int i) boolean
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()
toString()
Methods inherited from class java.util.LinkedHashSet
addFirst, addLast, getFirst, getLast, newLinkedHashSet, removeFirst, removeLast, reversed, spliterator
Methods inherited from class java.util.AbstractSet
removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll
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
-
Field Details
-
elements
Track the elements as they are added to the set
-
-
Constructor Details
-
OrderedHashSet
public OrderedHashSet()
-
-
Method Details
-
get
-
set
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
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
-
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
- Specified by:
equals
in interfaceCollection<T>
- Specified by:
equals
in interfaceSet<T>
- Overrides:
equals
in classAbstractSet<T>
-
iterator
-
elements
Return the List holding list of table elements. Note that you are NOT getting a copy so don't write to the list. -
clone
-
toArray
-
toString
- Overrides:
toString
in classAbstractCollection<T>
-