Class SmallScalingOrderedSet<E>
- java.lang.Object
-
- org.optaplanner.core.impl.domain.variable.listener.support.SmallScalingOrderedSet<E>
-
- Type Parameters:
E-
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
public final class SmallScalingOrderedSet<E> extends Object implements Set<E>
An orderedSetwhich is implemented as aArrayListfor a smallSet.size()and aLinkedHashSetfor 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 intLIST_SIZE_THRESHOLD
-
Constructor Summary
Constructors Constructor Description SmallScalingOrderedSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E e)booleanaddAll(Collection<? extends E> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)booleanisEmpty()Iterator<E>iterator()booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)intsize()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
-
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:
containsAllin interfaceCollection<E>- Specified by:
containsAllin 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)
-
-