Package org.immutables.ordinal
Class ImmutableOrdinalSet<E extends OrdinalValue<E>>
java.lang.Object
com.google.common.collect.ForwardingObject
com.google.common.collect.ForwardingCollection<E>
com.google.common.collect.ForwardingSet<E>
org.immutables.ordinal.ImmutableOrdinalSet<E>
- Type Parameters:
E- element type
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
- Direct Known Subclasses:
ImmutableOrdinalSet.EmptyImmutableOrdinalSet,ImmutableOrdinalSet.RegularImmutableOrdinalSet,ImmutableOrdinalSet.SingletonImmutableOrdinalSet
public abstract class ImmutableOrdinalSet<E extends OrdinalValue<E>>
extends com.google.common.collect.ForwardingSet<E>
Immutable set that take advantage of elements being an
OrdinalValues to provide
compact storage and efficient Set.contains(Object) and
Set.containsAll(Collection) operations.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classImmutableOrdinalSet.Builder<E extends OrdinalValue<E>>Build instances ofImmutableOrdinalSet.private static classprivate static classprivate static class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanDeprecated.Modification operation are not supported.final booleanaddAll(Collection<? extends E> newElements) Deprecated.Modification operation are not supported.static <E extends OrdinalValue<E>>
ImmutableOrdinalSet.Builder<E> builder()Build instances ofImmutableOrdinalSet.final voidclear()Deprecated.Modification operation are not supported.private static <E extends OrdinalValue<E>>
ImmutableOrdinalSet<E> constructFromArray(OrdinalValue<?>[] array) booleancontainsAny(Collection<?> collection) static <E extends OrdinalValue<E>>
ImmutableOrdinalSet<E> copyOf(E[] elements) Creates immutable ordinal set from array of elements.static <E extends OrdinalValue<E>>
ImmutableOrdinalSet<E> Creates immutable ordinal set from iterable of elements.abstract voidincrementCounters(int[] counters) Coarse grained method to effectively collect containment information without re-packing internal structures to temporary collections.static <E extends OrdinalValue<E>>
ImmutableOrdinalSet<E> of()Returns singleton empty immutable ordinal setstatic <E extends OrdinalValue<E>>
ImmutableOrdinalSet<E> of(E first, E... rest) Creates immutable ordinal set from 1 or more elements.final booleanDeprecated.Modification operation are not supported.final booleanremoveAll(Collection<?> oldElements) Deprecated.Modification operation are not supported.final booleanretainAll(Collection<?> elementsToKeep) Deprecated.Modification operation are not supported.Methods inherited from class com.google.common.collect.ForwardingSet
delegate, equals, hashCode, standardEquals, standardHashCode, standardRemoveAllMethods inherited from class com.google.common.collect.ForwardingCollection
contains, containsAll, isEmpty, iterator, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArrayMethods inherited from class com.google.common.collect.ForwardingObject
toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
contains, containsAll, isEmpty, iterator, size, spliterator, toArray, toArray
-
Field Details
-
EMPTY_SET
-
-
Constructor Details
-
ImmutableOrdinalSet
ImmutableOrdinalSet()
-
-
Method Details
-
of
Returns singleton empty immutable ordinal set- Type Parameters:
E- element type- Returns:
- empty set
-
of
@SafeVarargs public static <E extends OrdinalValue<E>> ImmutableOrdinalSet<E> of(E first, E... rest) Creates immutable ordinal set from 1 or more elements. All elements expected to have sameOrdinalValue.domain()as the first element, otherwise exception will be thrown.- Type Parameters:
E- element type- Parameters:
first- first elementrest- the rest of elements- Returns:
- empty set
-
copyOf
public static <E extends OrdinalValue<E>> ImmutableOrdinalSet<E> copyOf(Iterable<? extends E> elements) Creates immutable ordinal set from iterable of elements. All elements expected to have sameOrdinalValue.domain()as the first element, otherwise exception will be thrown.- Type Parameters:
E- the element type- Parameters:
elements- the elements, no nulls allowed- Returns:
- the immutable ordinal set
-
copyOf
Creates immutable ordinal set from array of elements. All elements expected to have sameOrdinalValue.domain()as the first element, otherwise exception will be thrown.- Type Parameters:
E- the element type- Parameters:
elements- the elements, no nulls allowed- Returns:
- the immutable ordinal set
-
constructFromArray
private static <E extends OrdinalValue<E>> ImmutableOrdinalSet<E> constructFromArray(OrdinalValue<?>[] array) -
add
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
addin interfaceCollection<E extends OrdinalValue<E>>- Specified by:
addin interfaceSet<E extends OrdinalValue<E>>- Overrides:
addin classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
UnsupportedOperationException- always
-
remove
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
removein interfaceCollection<E extends OrdinalValue<E>>- Specified by:
removein interfaceSet<E extends OrdinalValue<E>>- Overrides:
removein classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
UnsupportedOperationException- always
-
addAll
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
addAllin interfaceCollection<E extends OrdinalValue<E>>- Specified by:
addAllin interfaceSet<E extends OrdinalValue<E>>- Overrides:
addAllin classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
UnsupportedOperationException- always
-
removeAll
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
removeAllin interfaceCollection<E extends OrdinalValue<E>>- Specified by:
removeAllin interfaceSet<E extends OrdinalValue<E>>- Overrides:
removeAllin classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
UnsupportedOperationException- always
-
retainAll
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
retainAllin interfaceCollection<E extends OrdinalValue<E>>- Specified by:
retainAllin interfaceSet<E extends OrdinalValue<E>>- Overrides:
retainAllin classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
UnsupportedOperationException- always
-
clear
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
clearin interfaceCollection<E extends OrdinalValue<E>>- Specified by:
clearin interfaceSet<E extends OrdinalValue<E>>- Overrides:
clearin classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
UnsupportedOperationException- always
-
incrementCounters
public abstract void incrementCounters(int[] counters) Coarse grained method to effectively collect containment information without re-packing internal structures to temporary collections.For any contained element, corresponding value in array by ordinal index will be incremented.
- Parameters:
counters- array of counters where indexes corresponds to ordinal values- Throws:
RuntimeException- if counters array length do not correspond to ordinal indexes of contained values
-
containsAny
-
builder
Build instances ofImmutableOrdinalSet.- Type Parameters:
E- element type- Returns:
- builder
-