Package one.microstream.collections
Class ConstHashEnum<E>
- java.lang.Object
-
- one.microstream.collections.AbstractExtendedCollection<E>
-
- one.microstream.collections.AbstractChainCollection<E,E,E,ChainEntryLinkedStrong<E>>
-
- one.microstream.collections.ConstHashEnum<E>
-
- All Implemented Interfaces:
Iterable<E>,CapacityCarrying,ExtendedCollection<E>,ExtendedSequence<E>,HashCollection<E>,Sized,XGettingCollection<E>,XGettingEnum<E>,XGettingSequence<E>,XGettingSet<E>,XImmutableCollection<E>,XImmutableEnum<E>,XImmutableSequence<E>,XImmutableSet<E>,XIndexIterable<E>,XIterable<E>,XJoinable<E>,ThreadSafe,IdentityEqualityLogic,HashImmutable,Composition,Copyable,Immutable
public final class ConstHashEnum<E> extends AbstractChainCollection<E,E,E,ChainEntryLinkedStrong<E>> implements XImmutableEnum<E>, HashCollection<E>, Composition, IdentityEqualityLogic
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface one.microstream.typing.Copyable
Copyable.Static
-
Nested classes/interfaces inherited from interface one.microstream.collections.interfaces.ExtendedCollection
ExtendedCollection.Creator<E,C extends ExtendedCollection<E>>
-
Nested classes/interfaces inherited from interface one.microstream.collections.interfaces.HashCollection
HashCollection.Analysis<H>
-
Nested classes/interfaces inherited from interface one.microstream.collections.types.XGettingCollection
XGettingCollection.Creator<E>
-
Nested classes/interfaces inherited from interface one.microstream.collections.types.XGettingEnum
XGettingEnum.Creator<E>
-
Nested classes/interfaces inherited from interface one.microstream.collections.types.XGettingSet
XGettingSet.Creator<E>
-
Nested classes/interfaces inherited from interface one.microstream.collections.types.XImmutableEnum
XImmutableEnum.Factory<E>
-
Nested classes/interfaces inherited from interface one.microstream.collections.types.XIterable
XIterable.Executor<E>
-
-
Field Summary
-
Fields inherited from interface one.microstream.collections.interfaces.HashCollection
DEFAULT_HASH_FACTOR, DEFAULT_HASH_LENGTH
-
-
Constructor Summary
Constructors Constructor Description ConstHashEnum()
-
Method Summary
Modifier and Type Method Description HashCollection.Analysis<ConstHashEnum<E>>analyze()booleanapplies(Predicate<? super E> predicate)Eat(long index)booleancontains(E element)booleancontainsId(E element)Special version of contains() that guarantees to use identity comparison (" == ") when searching for the given element regardless of the collection's internal logic.
This method has the same behavior asXGettingCollection.containsSearched(Predicate)with aPredicateimplementation that checks for object identity.booleancontainsSearched(Predicate<? super E> predicate)ConstHashEnum<E>copy()Creates a true copy of this collection which references the same elements as this collection does at the time the method is called.<T extends Consumer<? super E>>
TcopySelection(T target, long... indices)<C extends Consumer<? super E>>
CcopyTo(C target)longcount(E entry)longcountBy(Predicate<? super E> predicate)<C extends Consumer<? super E>>
Cdistinct(C target)<C extends Consumer<? super E>>
Cdistinct(C target, Equalator<? super E> equalator)HashEqualator<E>equality()booleanequals(XGettingCollection<? extends E> samples, Equalator<? super E> equalator)Returnstrueif the passed collection is of the same type as this collection andthis.equalsContent(list, equalator)yieldstrue.booleanequalsContent(XGettingCollection<? extends E> samples, Equalator<? super E> equalator)Returnstrueif all elements of this list and the passed list are sequentially equal as defined by the passed equalator.<C extends Consumer<? super E>>
Cexcept(XGettingCollection<? extends E> other, Equalator<? super E> equalator, C target)<C extends Consumer<? super E>>
CfilterTo(C target, Predicate<? super E> predicate)Efirst()Eget()Gets one element from the collection.floathashDensity()inthashDistributionRange()HashEqualator<E>hashEquality()booleanhasVolatileElements()Tells if this collection contains volatile elements.
An element is volatile, if it can become no longer reachable by the collection without being removed from the collection.booleanhasVolatileHashElements()ConstHashEnum<E>immure()Always returns the already immutable collection instance itselflongindexBy(Predicate<? super E> predicate)longindexOf(E entry)<C extends Consumer<? super E>>
Cintersect(XGettingCollection<? extends E> other, Equalator<? super E> equalator, C target)booleanisEmpty()booleanisFull()Returns true if the current capacity cannot be increased any more.booleanisSorted(Comparator<? super E> comparator)<P extends Consumer<? super E>>
Piterate(P procedure)<P extends IndexedAcceptor<? super E>>
PiterateIndexed(P procedure)Iterator<E>iterator()<A> Ajoin(BiConsumer<? super E,? super A> joiner, A aggregate)Elast()longlastIndexBy(Predicate<? super E> predicate)longlastIndexOf(E entry)Emax(Comparator<? super E> comparator)longmaximumCapacity()Returns the maximum amount of elements this carrier instance can contain.
The actual value may be depend on the configuration of the concrete instance or may depend only on the implementation of the carrier (meaning it is constant for all instances of the implementation, e.g.longmaxIndex(Comparator<? super E> comparator)Emin(Comparator<? super E> comparator)longminIndex(Comparator<? super E> comparator)static <E> ConstHashEnum<E>New()static <E> ConstHashEnum<E>New(E... entries)static <E> ConstHashEnum<E>New(XGettingCollection<? extends E> entries)static <E> ConstHashEnum<E>NewCustom(float hashDensity, E... entries)static <E> ConstHashEnum<E>NewCustom(float hashDensity, XGettingCollection<? extends E> entries)static <E> ConstHashEnum<E>NewCustom(int initialCapacity)static <E> ConstHashEnum<E>NewCustom(int initialCapacity, float hashDensity)booleannullAllowed()booleannullContained()OldSet<E>old()Epeek()Epoll()XImmutableEnum<E>range(long lowIndex, long highIndex)intrehash()Recalculates the hash value of all entries and reorginazes and optimizes the hash storage accordingly.longremainingCapacity()Returns the amount of elements this carrier instance can collect before reaching its maximimum capacity.longscan(Predicate<? super E> predicate)Iterates through the collection and returns the index of the last element that the passedPredicateapplied to ("scanning").Esearch(Predicate<? super E> predicate)Eseek(E sample)Returns the first contained element matching the passed sample as defined by the collection's equality logic or null, if no fitting element is contained.voidsetHashDensity(float hashDensity)Sets the hash density (1/density) of this hashing collection if applicable.longsize()Object[]toArray()E[]toArray(Class<E> type)ConstHashEnum<E>toReversed()StringtoString()<C extends Consumer<? super E>>
Cunion(XGettingCollection<? extends E> other, Equalator<? super E> equalator, C target)XGettingEnum<E>view()XGettingEnum<E>view(long lowIndex, long highIndex)-
Methods inherited from class one.microstream.collections.AbstractExtendedCollection
ensureFreeArrayCapacity, validateIndex
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface one.microstream.hashing.HashImmutable
equals, hashCode
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface one.microstream.collections.types.XGettingCollection
containsAll, equals, hashCode, intSize
-
Methods inherited from interface one.microstream.collections.types.XGettingSequence
hasIndex
-
-
-
-
Method Detail
-
New
public static final <E> ConstHashEnum<E> New()
-
NewCustom
public static final <E> ConstHashEnum<E> NewCustom(int initialCapacity)
-
NewCustom
public static final <E> ConstHashEnum<E> NewCustom(int initialCapacity, float hashDensity)
-
NewCustom
public static final <E> ConstHashEnum<E> NewCustom(float hashDensity, XGettingCollection<? extends E> entries)
-
NewCustom
@SafeVarargs public static final <E> ConstHashEnum<E> NewCustom(float hashDensity, E... entries)
-
New
public static final <E> ConstHashEnum<E> New(XGettingCollection<? extends E> entries)
-
New
@SafeVarargs public static final <E> ConstHashEnum<E> New(E... entries)
-
nullAllowed
public boolean nullAllowed()
- Specified by:
nullAllowedin interfaceExtendedCollection<E>
-
size
public final long size()
- Specified by:
sizein interfaceHashCollection<E>- Specified by:
sizein interfaceSized- Specified by:
sizein interfaceXGettingCollection<E>
-
rehash
public final int rehash()
Description copied from interface:HashCollectionRecalculates the hash value of all entries and reorginazes and optimizes the hash storage accordingly. This method is meant for cases where a hash collection has to collect its elements before proper hash values can be derived for them or where hash mutable elements can change their hash-relevant state after having been added (and hashed) in a hash collection. Note that depending on the hash-relevant state of elements and their changing of it, it can be possible that some elements oust others, thus decreasing the collection's size. This behavior depends on the type of the elements and the used hash logic and cannot be compensated by a general purpose collection implementation.- Specified by:
rehashin interfaceHashCollection<E>- Returns:
- the new size of the collection which might be lower than before the call.
-
copy
public final ConstHashEnum<E> copy()
Description copied from interface:XGettingCollectionCreates a true copy of this collection which references the same elements as this collection does at the time the method is called. The elements themselves are NOT copied (no deep copying).
The type of the returned set is the same as of this list if possible.- Specified by:
copyin interfaceCopyable- Specified by:
copyin interfaceXGettingCollection<E>- Specified by:
copyin interfaceXGettingEnum<E>- Specified by:
copyin interfaceXGettingSequence<E>- Specified by:
copyin interfaceXGettingSet<E>- Specified by:
copyin interfaceXImmutableCollection<E>- Specified by:
copyin interfaceXImmutableEnum<E>- Specified by:
copyin interfaceXImmutableSequence<E>- Specified by:
copyin interfaceXImmutableSet<E>- Returns:
- a copy of this list
-
immure
public final ConstHashEnum<E> immure()
Description copied from interface:XImmutableEnumAlways returns the already immutable collection instance itselfFor spawning a copy of the collection instance, see
XImmutableCollection.copy()- Specified by:
immurein interfaceXGettingCollection<E>- Specified by:
immurein interfaceXGettingEnum<E>- Specified by:
immurein interfaceXGettingSequence<E>- Specified by:
immurein interfaceXGettingSet<E>- Specified by:
immurein interfaceXImmutableCollection<E>- Specified by:
immurein interfaceXImmutableEnum<E>- Specified by:
immurein interfaceXImmutableSequence<E>- Specified by:
immurein interfaceXImmutableSet<E>- Returns:
- a reference to the instance itself.
- See Also:
XImmutableCollection.copy()
-
view
public final XGettingEnum<E> view()
- Specified by:
viewin interfaceXGettingCollection<E>- Specified by:
viewin interfaceXGettingEnum<E>- Specified by:
viewin interfaceXGettingSequence<E>
-
setHashDensity
public final void setHashDensity(float hashDensity)
Description copied from interface:HashCollectionSets the hash density (1/density) of this hashing collection if applicable.If this procedure is not applicable for the hash collection (e.g. an immutable hash collection), calling this method has no effect.
- Specified by:
setHashDensityin interfaceHashCollection<E>- Parameters:
hashDensity- the new hash density to be set.
-
hasVolatileElements
public final boolean hasVolatileElements()
Description copied from interface:XGettingCollectionTells if this collection contains volatile elements.
An element is volatile, if it can become no longer reachable by the collection without being removed from the collection. Examples areWeakReferenceofSoftReferenceor implementations of collection entries that remove the element contained in an entry by some means outside the collection.
Note thatWeakReferenceinstances that are added to a a simple (non-volatile) implementation of a collection do NOT make the collection volatile, as the elements themselves (the reference instances) are still strongly referenced.- Specified by:
hasVolatileElementsin interfaceExtendedCollection<E>- Specified by:
hasVolatileElementsin interfaceXGettingCollection<E>- Returns:
trueif the collection contains volatile elements.
-
old
public final OldSet<E> old()
- Specified by:
oldin interfaceXGettingCollection<E>
-
maximumCapacity
public final long maximumCapacity()
Description copied from interface:CapacityCarryingReturns the maximum amount of elements this carrier instance can contain.
The actual value may be depend on the configuration of the concrete instance or may depend only on the implementation of the carrier (meaning it is constant for all instances of the implementation, e.g.Integer.MAX_VALUE)- Specified by:
maximumCapacityin interfaceCapacityCarrying- Returns:
- the maximum amount of elements this carrier instance can contain.
-
isFull
public final boolean isFull()
Description copied from interface:CapacityCarryingReturns true if the current capacity cannot be increased any more.- Specified by:
isFullin interfaceCapacityCarrying
-
remainingCapacity
public final long remainingCapacity()
Description copied from interface:CapacityCarryingReturns the amount of elements this carrier instance can collect before reaching its maximimum capacity.- Specified by:
remainingCapacityin interfaceCapacityCarrying
-
analyze
public final HashCollection.Analysis<ConstHashEnum<E>> analyze()
- Specified by:
analyzein interfaceHashCollection<E>
-
hashDistributionRange
public final int hashDistributionRange()
- Specified by:
hashDistributionRangein interfaceHashCollection<E>
-
hashEquality
public final HashEqualator<E> hashEquality()
- Specified by:
hashEqualityin interfaceHashCollection<E>
-
hashDensity
public final float hashDensity()
- Specified by:
hashDensityin interfaceHashCollection<E>
-
hasVolatileHashElements
public final boolean hasVolatileHashElements()
- Specified by:
hasVolatileHashElementsin interfaceHashCollection<E>
-
range
public final XImmutableEnum<E> range(long lowIndex, long highIndex)
- Specified by:
rangein interfaceXGettingEnum<E>- Specified by:
rangein interfaceXGettingSequence<E>
-
view
public final XGettingEnum<E> view(long lowIndex, long highIndex)
- Specified by:
viewin interfaceXGettingEnum<E>- Specified by:
viewin interfaceXGettingSequence<E>
-
toArray
public final E[] toArray(Class<E> type)
- Specified by:
toArrayin interfaceXGettingCollection<E>
-
iterate
public final <P extends Consumer<? super E>> P iterate(P procedure)
- Specified by:
iteratein interfaceXGettingEnum<E>- Specified by:
iteratein interfaceXGettingSet<E>- Specified by:
iteratein interfaceXIterable<E>
-
join
public final <A> A join(BiConsumer<? super E,? super A> joiner, A aggregate)
-
count
public final long count(E entry)
- Specified by:
countin interfaceXGettingCollection<E>
-
countBy
public final long countBy(Predicate<? super E> predicate)
- Specified by:
countByin interfaceXGettingCollection<E>
-
search
public final E search(Predicate<? super E> predicate)
- Specified by:
searchin interfaceXGettingCollection<E>
-
max
public final E max(Comparator<? super E> comparator)
- Specified by:
maxin interfaceXGettingCollection<E>
-
min
public final E min(Comparator<? super E> comparator)
- Specified by:
minin interfaceXGettingCollection<E>
-
containsSearched
public final boolean containsSearched(Predicate<? super E> predicate)
- Specified by:
containsSearchedin interfaceXGettingCollection<E>
-
applies
public final boolean applies(Predicate<? super E> predicate)
- Specified by:
appliesin interfaceXGettingCollection<E>
-
nullContained
public final boolean nullContained()
- Specified by:
nullContainedin interfaceXGettingCollection<E>
-
containsId
public final boolean containsId(E element)
Description copied from interface:XGettingCollectionSpecial version of contains() that guarantees to use identity comparison (" == ") when searching for the given element regardless of the collection's internal logic.
This method has the same behavior asXGettingCollection.containsSearched(Predicate)with aPredicateimplementation that checks for object identity. The only difference is a performance and usability advantage- Specified by:
containsIdin interfaceXGettingCollection<E>- Parameters:
element- the element to be searched in the collection by identity.- Returns:
- whether this collection contains exactely the given element.
-
contains
public final boolean contains(E element)
- Specified by:
containsin interfaceXGettingCollection<E>
-
seek
public final E seek(E sample)
Description copied from interface:XGettingCollectionReturns the first contained element matching the passed sample as defined by the collection's equality logic or null, if no fitting element is contained. (For collections using referential equality, this method is basically just a variation ofXGettingCollection.contains(Object)with a different return type. For collections with data-dependant equality, the returned element might be the same as the passed one or a data-wise equal one, depending on the content of the collection)- Specified by:
seekin interfaceXGettingCollection<E>
-
equals
public final boolean equals(XGettingCollection<? extends E> samples, Equalator<? super E> equalator)
Description copied from interface:XGettingCollectionReturnstrueif the passed collection is of the same type as this collection andthis.equalsContent(list, equalator)yieldstrue.- Specified by:
equalsin interfaceXGettingCollection<E>
-
equalsContent
public final boolean equalsContent(XGettingCollection<? extends E> samples, Equalator<? super E> equalator)
Description copied from interface:XGettingCollectionReturnstrueif all elements of this list and the passed list are sequentially equal as defined by the passed equalator.Note that for colletion types that don't have a defined order of elements, this method is hardly usable (as is
XGettingCollection.equals(Object)for them as defined inCollection). The core problem of comparing collections that have no defined order is that they aren't really reliably comparable to any other collection.- Specified by:
equalsContentin interfaceXGettingCollection<E>equalator- the equalator to use to determine the equality of each element- Returns:
trueif this list is equal to the passed list, false otherwise
-
intersect
public final <C extends Consumer<? super E>> C intersect(XGettingCollection<? extends E> other, Equalator<? super E> equalator, C target)
- Specified by:
intersectin interfaceXGettingCollection<E>
-
except
public final <C extends Consumer<? super E>> C except(XGettingCollection<? extends E> other, Equalator<? super E> equalator, C target)
- Specified by:
exceptin interfaceXGettingCollection<E>
-
union
public final <C extends Consumer<? super E>> C union(XGettingCollection<? extends E> other, Equalator<? super E> equalator, C target)
- Specified by:
unionin interfaceXGettingCollection<E>
-
copyTo
public final <C extends Consumer<? super E>> C copyTo(C target)
- Specified by:
copyToin interfaceXGettingCollection<E>
-
filterTo
public final <C extends Consumer<? super E>> C filterTo(C target, Predicate<? super E> predicate)
- Specified by:
filterToin interfaceXGettingCollection<E>
-
distinct
public final <C extends Consumer<? super E>> C distinct(C target)
- Specified by:
distinctin interfaceXGettingCollection<E>
-
distinct
public final <C extends Consumer<? super E>> C distinct(C target, Equalator<? super E> equalator)
- Specified by:
distinctin interfaceXGettingCollection<E>
-
toReversed
public final ConstHashEnum<E> toReversed()
- Specified by:
toReversedin interfaceXGettingEnum<E>- Specified by:
toReversedin interfaceXGettingSequence<E>- Specified by:
toReversedin interfaceXImmutableEnum<E>- Specified by:
toReversedin interfaceXImmutableSequence<E>
-
copySelection
public final <T extends Consumer<? super E>> T copySelection(T target, long... indices)
- Specified by:
copySelectionin interfaceXGettingSequence<E>
-
iterateIndexed
public final <P extends IndexedAcceptor<? super E>> P iterateIndexed(P procedure)
- Specified by:
iterateIndexedin interfaceXIndexIterable<E>
-
at
public final E at(long index)
- Specified by:
atin interfaceXGettingSequence<E>
-
get
public final E get()
Description copied from interface:XGettingCollectionGets one element from the collection. If the collection is not orderedXGettingSequence, then it is undefined which element is returned. If the collection is ordered, the element at index 0 is returned.- Specified by:
getin interfaceXGettingCollection<E>- Specified by:
getin interfaceXGettingSequence<E>- Returns:
- the first / any element.
- See Also:
XGettingSequence.at(long),XGettingSequence.first(),XGettingSequence.last()
-
first
public final E first()
- Specified by:
firstin interfaceXGettingSequence<E>
-
last
public final E last()
- Specified by:
lastin interfaceXGettingSequence<E>
-
poll
public final E poll()
- Specified by:
pollin interfaceXGettingSequence<E>
-
peek
public final E peek()
- Specified by:
peekin interfaceXGettingSequence<E>
-
indexOf
public final long indexOf(E entry)
- Specified by:
indexOfin interfaceXGettingSequence<E>
-
indexBy
public final long indexBy(Predicate<? super E> predicate)
- Specified by:
indexByin interfaceXGettingSequence<E>
-
isSorted
public final boolean isSorted(Comparator<? super E> comparator)
- Specified by:
isSortedin interfaceXGettingSequence<E>
-
lastIndexOf
public final long lastIndexOf(E entry)
- Specified by:
lastIndexOfin interfaceXGettingSequence<E>
-
lastIndexBy
public final long lastIndexBy(Predicate<? super E> predicate)
- Specified by:
lastIndexByin interfaceXGettingSequence<E>
-
maxIndex
public final long maxIndex(Comparator<? super E> comparator)
- Specified by:
maxIndexin interfaceXGettingSequence<E>
-
minIndex
public final long minIndex(Comparator<? super E> comparator)
- Specified by:
minIndexin interfaceXGettingSequence<E>
-
scan
public final long scan(Predicate<? super E> predicate)
Description copied from interface:XGettingSequenceIterates through the collection and returns the index of the last element that the passedPredicateapplied to ("scanning").- Specified by:
scanin interfaceXGettingSequence<E>- Returns:
- the index of the last positively tested element.
-
toArray
public final Object[] toArray()
- Specified by:
toArrayin interfaceXGettingCollection<E>
-
equality
public final HashEqualator<E> equality()
- Specified by:
equalityin interfaceXGettingCollection<E>
-
-