Package org.optaplanner.core.impl.util
Class ListBasedScalingOrderedSet<E>
java.lang.Object
org.optaplanner.core.impl.util.ListBasedScalingOrderedSet<E>
- Type Parameters:
E
-
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
An ordered
Set
which is implemented as a ArrayList
for a small Set.size()
and a LinkedHashSet
for a big Set.size()
.
This speeds up add(Object)
performance (in some cases by 20%) if most instances have a small size
because no Object.hashCode()
need to be calculated.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends E> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
isEmpty()
iterator()
boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] a) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Field Details
-
LIST_SIZE_THRESHOLD
protected static final int LIST_SIZE_THRESHOLD- See Also:
-
-
Constructor Details
-
ListBasedScalingOrderedSet
public ListBasedScalingOrderedSet()
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
-
iterator
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
add
-
addAll
-
remove
-
retainAll
-
removeAll
-
clear
public void clear()
-