Package org.plumelib.util
Class IdentityArraySet<E extends @UnknownSignedness Object>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.plumelib.util.IdentityArraySet<E>
- Type Parameters:
E
- the type of the set elements
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
A set backed by an array. It uses object identity (==) for comparison. It permits null values and
its iterator has deterministic ordering.
Compared to a set built on IdentityHashMap: For very small sets, this uses much less space, has comparable performance, and (like a LinkedHashSet) is deterministic, with elements returned in the order they were inserted. For large sets, this is significantly less performant than other set implementations.
-
Constructor Summary
ConstructorDescriptionConstructs an emptyIdentityArraySet
with the default initial capacity.IdentityArraySet
(int initialCapacity) Constructs an emptyIdentityArraySet
with the specified initial capacity.IdentityArraySet
(Collection<? extends E> m) Constructs a newIdentityArraySet
with the same elements as the given collection. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends E> c) void
clear()
clone()
Returns a copy of this.boolean
void
boolean
isEmpty()
iterator()
boolean
boolean
removeAll
(Collection<?> c) @org.checkerframework.checker.index.qual.NonNegative int
size()
Methods inherited from class java.util.AbstractSet
equals, hashCode
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray, toString
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
Methods inherited from interface java.util.Set
containsAll, retainAll, spliterator, toArray, toArray
-
Constructor Details
-
IdentityArraySet
@SideEffectFree public IdentityArraySet(int initialCapacity) Constructs an emptyIdentityArraySet
with the specified initial capacity.- Parameters:
initialCapacity
- the initial capacity- Throws:
IllegalArgumentException
- if the initial capacity is negative
-
IdentityArraySet
@SideEffectFree public IdentityArraySet()Constructs an emptyIdentityArraySet
with the default initial capacity. -
IdentityArraySet
Constructs a newIdentityArraySet
with the same elements as the given collection.- Parameters:
m
- the collection whose elements are to be placed in the new set- Throws:
NullPointerException
- if the given set is null
-
-
Method Details
-
size
@Pure public @org.checkerframework.checker.index.qual.NonNegative int size() -
isEmpty
@Pure public boolean isEmpty() -
contains
-
add
-
remove
-
addAll
-
removeAll
-
clear
public void clear() -
iterator
- Specified by:
iterator
in interfaceCollection<E extends @UnknownSignedness Object>
- Specified by:
iterator
in interfaceIterable<E extends @UnknownSignedness Object>
- Specified by:
iterator
in interfaceSet<E extends @UnknownSignedness Object>
- Specified by:
iterator
in classAbstractCollection<E extends @UnknownSignedness Object>
-
forEach
-
clone
Returns a copy of this.
-