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>
public final class ListBasedScalingOrderedSet<E> extends Object implements Set<E>
An orderedSet
which is implemented as aArrayList
for a smallSet.size()
and aLinkedHashSet
for a bigSet.size()
.This speeds up
add(Object)
performance (in some cases by 20%) if most instances have a small size because noObject.hashCode()
need to be calculated.
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
LIST_SIZE_THRESHOLD
-
Constructor Summary
Constructors Constructor Description ListBasedScalingOrderedSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(E e)
boolean
addAll(Collection<? extends E> c)
void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
boolean
isEmpty()
Iterator<E>
iterator()
boolean
remove(Object o)
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 Detail
-
LIST_SIZE_THRESHOLD
protected static final int LIST_SIZE_THRESHOLD
- See Also:
- Constant Field Values
-
-
Method Detail
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
add
public boolean add(E e)
-
addAll
public boolean addAll(Collection<? extends E> c)
-
remove
public boolean remove(Object o)
-
retainAll
public boolean retainAll(Collection<?> c)
-
removeAll
public boolean removeAll(Collection<?> c)
-
-