Package arc.struct
Class OrderedSet<T>
java.lang.Object
arc.struct.ObjectSet<T>
arc.struct.OrderedSet<T>
An
ObjectSet that also stores keys in an Seq using the insertion order. Iteration is
ordered and faster than an unordered set. Keys can also be accessed and the order changed using orderedItems(). There
is some additional overhead for put and remove. When used for faster iteration versus ObjectSet and the order does not actually
matter, copying during remove can be greatly reduced by setting Seq.ordered to false for
orderedItems().-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class arc.struct.ObjectSet
ObjectSet.ObjectSetIterator -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionOrderedSet(int initialCapacity) OrderedSet(int initialCapacity, float loadFactor) OrderedSet(OrderedSet<T> set) -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if the key was not already in the set.booleanvoidclear()Clears the set, leaving the backing arrays at the current capacity.voidclear(int maximumCapacity) Clears the set and reduces the size of the backing arrays to be the specified capacity, if they are larger.first()iterator()Returns an iterator for the keys in the set.booleanReturns true if the key was removed.removeIndex(int index) toString()Methods inherited from class arc.struct.ObjectSet
addAll, addAll, addAll, addAll, addAll, contains, copy, each, ensureCapacity, equals, find, get, hashCode, isEmpty, removeAll, removeAll, removeAll, select, shrink, toSeq, with, withMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
OrderedSet
public OrderedSet() -
OrderedSet
public OrderedSet(int initialCapacity, float loadFactor) -
OrderedSet
public OrderedSet(int initialCapacity) -
OrderedSet
-
-
Method Details
-
first
-
add
Description copied from class:ObjectSetReturns true if the key was not already in the set. If this set already contains the key, the call leaves the set unchanged and returns false. -
add
-
remove
Description copied from class:ObjectSetReturns true if the key was removed. -
removeIndex
-
clear
public void clear(int maximumCapacity) Description copied from class:ObjectSetClears the set and reduces the size of the backing arrays to be the specified capacity, if they are larger. The reduction is done by allocating new arrays, though for large arrays this can be faster than clearing the existing array. -
clear
public void clear()Description copied from class:ObjectSetClears the set, leaving the backing arrays at the current capacity. When the capacity is high and the population is low, iteration can be unnecessarily slow.ObjectSet.clear(int)can be used to reduce the capacity. -
orderedItems
-
iterator
Description copied from class:ObjectSetReturns an iterator for the keys in the set. Remove is supported. Note that the same iterator instance is returned each time this method is called. Use theObjectSet<T>.ObjectSetIteratorconstructor for nested or multithreaded iteration. -
toString
-
toString
-