Package org.plumelib.util
Class MostlySingletonSet<T>
java.lang.Object
org.plumelib.util.AbstractMostlySingletonSet<T>
org.plumelib.util.MostlySingletonSet<T>
- Type Parameters:
T
- the type of elements of the set
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,Set<T>
A set that is more efficient than HashSet for 0 and 1 elements. Uses
Objects.equals
for
object comparison and a LinkedHashSet
for backing storage.
Usually, you should use ArraySet
instead. The advantage of this over ArraySet
is that this is efficient for large sets.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.plumelib.util.AbstractMostlySingletonSet
AbstractMostlySingletonSet.State
-
Field Summary
Fields inherited from class org.plumelib.util.AbstractMostlySingletonSet
set, state, value
-
Constructor Summary
ConstructorDescriptionCreate a MostlySingletonSet.MostlySingletonSet
(T value) Create a MostlySingletonSet containing one value. -
Method Summary
Methods inherited from class org.plumelib.util.AbstractMostlySingletonSet
addAll, checkRep, clear, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Constructor Details
-
MostlySingletonSet
public MostlySingletonSet()Create a MostlySingletonSet. -
MostlySingletonSet
Create a MostlySingletonSet containing one value.- Parameters:
value
- the single element of the set
-
-
Method Details
-
add
-
contains
public boolean contains(@GuardSatisfied MostlySingletonSet<T> this, @GuardSatisfied @UnknownSignedness Object o)
-