Package org.optaplanner.core.impl.util
Class FieldBasedScalingSet<E>
- java.lang.Object
-
- org.optaplanner.core.impl.util.FieldBasedScalingSet<E>
-
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
public final class FieldBasedScalingSet<E> extends Object implements Set<E>
Uses a givenSetas storage unless it is the first and only value, in which case it uses a field. This helps avoid the overhead of creating and accessing the set if we only have 1 value. This implementation is not thread-safe, regardless of the underlyingSet. Iteration order of elements is specified by the underlyingSet.
-
-
Constructor Summary
Constructors Constructor Description FieldBasedScalingSet(Supplier<Set<E>> setSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E value)booleanaddAll(Collection<? extends E> c)voidclear()booleancontains(Object value)booleancontainsAll(Collection<?> c)voidforEach(Consumer<? super E> action)booleanisEmpty()Iterator<E>iterator()As defined bySet.iterator().booleanremove(Object value)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)intsize()Object[]toArray()<T> T[]toArray(T[] a)StringtoString()-
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
-
-
-
-
Method Detail
-
add
public boolean add(E value)
-
clear
public void clear()
-
remove
public boolean remove(Object value)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>
-
addAll
public boolean addAll(Collection<? extends E> c)
-
retainAll
public boolean retainAll(Collection<?> c)
-
removeAll
public boolean removeAll(Collection<?> c)
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object value)
-
iterator
public Iterator<E> iterator()
As defined bySet.iterator(). May throw an exception if the iterator is used to remove an element while the set is based on a field.
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
-