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:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.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 anOrdinalValues to provide compact storage and efficientSet.contains(Object)andSet.containsAll(Collection)operations.- See Also:
OrdinalValue,OrdinalDomain,BitSet for similar internal implementation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableOrdinalSet.Builder<E extends OrdinalValue<E>>Build instances ofImmutableOrdinalSet.private static classImmutableOrdinalSet.EmptyImmutableOrdinalSet<E extends OrdinalValue<E>>private static classImmutableOrdinalSet.RegularImmutableOrdinalSet<E extends OrdinalValue<E>>private static classImmutableOrdinalSet.SingletonImmutableOrdinalSet<E extends OrdinalValue<E>>
-
Field Summary
Fields Modifier and Type Field Description private static ImmutableOrdinalSet<?>EMPTY_SET
-
Constructor Summary
Constructors Constructor Description ImmutableOrdinalSet()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanadd(E e)Deprecated.Modification operation are not supported.booleanaddAll(java.util.Collection<? extends E> newElements)Deprecated.Modification operation are not supported.static <E extends OrdinalValue<E>>
ImmutableOrdinalSet.Builder<E>builder()Build instances ofImmutableOrdinalSet.voidclear()Deprecated.Modification operation are not supported.private static <E extends OrdinalValue<E>>
ImmutableOrdinalSet<E>constructFromArray(OrdinalValue<?>[] array)booleancontainsAny(java.util.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>copyOf(java.lang.Iterable<? extends E> elements)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.booleanremove(java.lang.Object object)Deprecated.Modification operation are not supported.booleanremoveAll(java.util.Collection<?> oldElements)Deprecated.Modification operation are not supported.booleanretainAll(java.util.Collection<?> elementsToKeep)Deprecated.Modification operation are not supported.-
Methods inherited from class com.google.common.collect.ForwardingSet
delegate, equals, hashCode, standardEquals, standardHashCode, standardRemoveAll
-
Methods inherited from class com.google.common.collect.ForwardingCollection
contains, containsAll, isEmpty, iterator, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray
-
-
-
-
Field Detail
-
EMPTY_SET
private static final ImmutableOrdinalSet<?> EMPTY_SET
-
-
Method Detail
-
of
public static <E extends OrdinalValue<E>> ImmutableOrdinalSet<E> 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(java.lang.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
public static <E extends OrdinalValue<E>> ImmutableOrdinalSet<E> copyOf(E[] elements)
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 public final boolean add(E e)
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
addin interfacejava.util.Collection<E extends OrdinalValue<E>>- Specified by:
addin interfacejava.util.Set<E extends OrdinalValue<E>>- Overrides:
addin classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
java.lang.UnsupportedOperationException- always
-
remove
@Deprecated public final boolean remove(java.lang.Object object)
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
removein interfacejava.util.Collection<E extends OrdinalValue<E>>- Specified by:
removein interfacejava.util.Set<E extends OrdinalValue<E>>- Overrides:
removein classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
java.lang.UnsupportedOperationException- always
-
addAll
@Deprecated public final boolean addAll(java.util.Collection<? extends E> newElements)
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
addAllin interfacejava.util.Collection<E extends OrdinalValue<E>>- Specified by:
addAllin interfacejava.util.Set<E extends OrdinalValue<E>>- Overrides:
addAllin classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
java.lang.UnsupportedOperationException- always
-
removeAll
@Deprecated public final boolean removeAll(java.util.Collection<?> oldElements)
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
removeAllin interfacejava.util.Collection<E extends OrdinalValue<E>>- Specified by:
removeAllin interfacejava.util.Set<E extends OrdinalValue<E>>- Overrides:
removeAllin classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
java.lang.UnsupportedOperationException- always
-
retainAll
@Deprecated public final boolean retainAll(java.util.Collection<?> elementsToKeep)
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
retainAllin interfacejava.util.Collection<E extends OrdinalValue<E>>- Specified by:
retainAllin interfacejava.util.Set<E extends OrdinalValue<E>>- Overrides:
retainAllin classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
java.lang.UnsupportedOperationException- always
-
clear
@Deprecated public final void clear()
Deprecated.Modification operation are not supported.Will throw an exception and leave the collection unmodified.- Specified by:
clearin interfacejava.util.Collection<E extends OrdinalValue<E>>- Specified by:
clearin interfacejava.util.Set<E extends OrdinalValue<E>>- Overrides:
clearin classcom.google.common.collect.ForwardingCollection<E extends OrdinalValue<E>>- Throws:
java.lang.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:
java.lang.RuntimeException- if counters array length do not correspond to ordinal indexes of contained values
-
containsAny
public boolean containsAny(java.util.Collection<?> collection)
-
builder
public static <E extends OrdinalValue<E>> ImmutableOrdinalSet.Builder<E> builder()
Build instances ofImmutableOrdinalSet.- Type Parameters:
E- element type- Returns:
- builder
-
-