Package one.microstream.util.traversing
Class OpenAdressingMiniSet<E>
java.lang.Object
one.microstream.util.traversing.OpenAdressingMiniSet<E>
- Type Parameters:
E-
- All Implemented Interfaces:
Iterable<E>,Consumer<E>,CapacityCarrying,CapacityExtendable,ConsolidatableCollection,ExtendedCollection<E>,OptimizableCollection,ReleasingCollection<E>,Sized,Truncateable,XAddGetCollection<E>,XAddGetSet<E>,XAddingCollection<E>,XAddingSet<E>,XCollection<E>,XGettingCollection<E>,XGettingSet<E>,XIterable<E>,XJoinable<E>,XProcessingCollection<E>,XProcessingSet<E>,XPutGetCollection<E>,XPutGetSet<E>,XPuttingCollection<E>,XPuttingSet<E>,XRemovingCollection<E>,XRemovingSet<E>,XSet<E>,Processable<E>,Clearable,Copyable
public final class OpenAdressingMiniSet<E> extends Object implements XSet<E>
Very primitive, but very fast open adressing hash
Drawbacks:
- only add() implemented so far - even if fully implemented, the implementation would have no order and is technically restricted to a maximum element count equal to the maximum array length. Chain-based implementations do not have such a restriction.
XSet implementation.
It is considerable faster than general purpose hash collections like HashEnum, which use
chains instead of open adressing for resolving hash collisions. It also scales much better with higher element count.
Drawbacks:
- only add() implemented so far - even if fully implemented, the implementation would have no order and is technically restricted to a maximum element count equal to the maximum array length. Chain-based implementations do not have such a restriction.
-
Nested Class Summary
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.types.XAddGetCollection
XAddGetCollection.Creator<E>Nested classes/interfaces inherited from interface one.microstream.collections.types.XAddingSet
XAddingSet.Creator<E>Nested classes/interfaces inherited from interface one.microstream.collections.types.XGettingCollection
XGettingCollection.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.XIterable
XIterable.Executor<E>Nested classes/interfaces inherited from interface one.microstream.collections.types.XPutGetCollection
XPutGetCollection.Creator<E>Nested classes/interfaces inherited from interface one.microstream.collections.types.XPuttingSet
XPuttingSet.Creator<E>Nested classes/interfaces inherited from interface one.microstream.collections.types.XSet
XSet.Factory<E> -
Constructor Summary
Constructors Constructor Description OpenAdressingMiniSet() -
Method Summary
Modifier and Type Method Description voidaccept(E t)booleanadd(E element)XSet<E>addAll(E... elements)XSet<E>addAll(E[] elements, int srcStartIndex, int srcLength)XSet<E>addAll(XGettingCollection<? extends E> elements)EaddGet(E element)booleanapplies(Predicate<? super E> predicate)voidclear()Clears all elements from the collection while leaving the capacity as it is.longconsolidate()Consolidates the internal storage of this collection by discarding all elements of the internal storage that have become obsolete or otherwise unneeded anymore.booleancontains(E element)booleancontainsAll(XGettingCollection<? extends E> elements)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)XSet<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>>
TcopyTo(T target)longcount(E element)longcountBy(Predicate<? super E> predicate)longcurrentCapacity()Returns the current amount of elements this instance can hold before a storage rebuild becomes necessary.Ededuplicate(E element)<T extends Consumer<? super E>>
Tdistinct(T target)<T extends Consumer<? super E>>
Tdistinct(T target, Equalator<? super E> equalator)CapacityExtendableensureCapacity(long minimalCapacity)CapacityExtendableensureFreeCapacity(long minimalFreeCapacity)Ensures that the next minimalFreeCapacity elements can be actually added in a fast way, meaning for example no internal storage rebuild will be necessary.Equalator<? super 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.<T extends Consumer<? super E>>
Texcept(XGettingCollection<? extends E> other, Equalator<? super E> equalator, T target)Efetch()<T extends Consumer<? super E>>
TfilterTo(T target, Predicate<? super E> predicate)Eget()Gets one element from the collection.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.XImmutableSet<E>immure()Provides an instance of an immutable collection type with equal behavior and data as this instance.<T extends Consumer<? super E>>
Tintersect(XGettingCollection<? extends E> other, Equalator<? super E> equalator, T target)<P extends Consumer<? super E>>
Piterate(P procedure)Iterator<E>iterator()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.Emin(Comparator<? super E> comparator)<C extends Consumer<? super E>>
CmoveTo(C target, Predicate<? super E> predicate)static <E> OpenAdressingMiniSet<E>New()static <E> OpenAdressingMiniSet<E>New(int initialCapacity)static <E> OpenAdressingMiniSet<E>New(XGettingCollection<? extends E> elements)booleannullAdd()booleannullAllowed()booleannullContained()booleannullPut()longnullRemove()OldCollection<E>old()longoptimize()Optimizes the internal storage of this collection and returns the storage size of the collection after the process is complete.Epinch()<P extends Consumer<? super E>>
Pprocess(P processor)booleanput(E element)XSet<E>putAll(E... elements)XSet<E>putAll(E[] elements, int srcStartIndex, int srcLength)XSet<E>putAll(XGettingCollection<? extends E> elements)EputGet(E element)longremove(E element)longremoveAll(XGettingCollection<? extends E> elements)longremoveBy(Predicate<? super E> predicate)longremoveDuplicates()longremoveDuplicates(Equalator<? super E> equalator)booleanremoveOne(E element)Ereplace(E element)longretainAll(XGettingCollection<? extends E> elements)Eretrieve(E element)EretrieveBy(Predicate<? super E> predicate)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.longsize()Object[]toArray()E[]toArray(Class<E> type)StringtoString()voidtruncate()Clears (and reinitializes if needed) this collection in the fastest possible way, i.e.<T extends Consumer<? super E>>
Tunion(XGettingCollection<? extends E> other, Equalator<? super E> equalator, T target)XGettingCollection<E>view()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface one.microstream.collections.interfaces.CapacityCarrying
isFull, remainingCapacityMethods inherited from interface one.microstream.collections.interfaces.CapacityExtendable
currentFreeCapacityMethods inherited from interface one.microstream.collections.types.XGettingCollection
equals, hashCode, intSize, join
-
Constructor Details
-
OpenAdressingMiniSet
public OpenAdressingMiniSet()
-
-
Method Details
-
New
-
New
-
New
-
add
- Specified by:
addin interfaceXAddingCollection<E>
-
size
public long size()- Specified by:
sizein interfaceSized- Specified by:
sizein interfaceXGettingCollection<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>- Returns:
- the first / any element.
-
iterator
-
toArray
- Specified by:
toArrayin interfaceXGettingCollection<E>
-
toArray
- Specified by:
toArrayin interfaceXGettingCollection<E>
-
old
- Specified by:
oldin interfaceXGettingCollection<E>
-
hasVolatileElements
public 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.
-
equality
- Specified by:
equalityin interfaceXGettingCollection<E>
-
equals
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 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
-
view
- Specified by:
viewin interfaceXGettingCollection<E>
-
nullContained
public boolean nullContained()- Specified by:
nullContainedin interfaceXGettingCollection<E>
-
containsId
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
- Specified by:
containsin interfaceXGettingCollection<E>
-
containsSearched
- Specified by:
containsSearchedin interfaceXGettingCollection<E>
-
containsAll
- Specified by:
containsAllin interfaceXGettingCollection<E>
-
applies
- Specified by:
appliesin interfaceXGettingCollection<E>
-
count
- Specified by:
countin interfaceXGettingCollection<E>
-
countBy
- Specified by:
countByin interfaceXGettingCollection<E>
-
search
- Specified by:
searchin interfaceXGettingCollection<E>
-
seek
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>
-
max
- Specified by:
maxin interfaceXGettingCollection<E>
-
min
- Specified by:
minin interfaceXGettingCollection<E>
-
distinct
- Specified by:
distinctin interfaceXGettingCollection<E>
-
distinct
- Specified by:
distinctin interfaceXGettingCollection<E>
-
copyTo
- Specified by:
copyToin interfaceXGettingCollection<E>
-
filterTo
- Specified by:
filterToin interfaceXGettingCollection<E>
-
union
public <T extends Consumer<? super E>> T union(XGettingCollection<? extends E> other, Equalator<? super E> equalator, T target)- Specified by:
unionin interfaceXGettingCollection<E>
-
intersect
public <T extends Consumer<? super E>> T intersect(XGettingCollection<? extends E> other, Equalator<? super E> equalator, T target)- Specified by:
intersectin interfaceXGettingCollection<E>
-
except
public <T extends Consumer<? super E>> T except(XGettingCollection<? extends E> other, Equalator<? super E> equalator, T target)- Specified by:
exceptin interfaceXGettingCollection<E>
-
iterate
- Specified by:
iteratein interfaceXGettingSet<E>- Specified by:
iteratein interfaceXIterable<E>- Specified by:
iteratein interfaceXProcessingCollection<E>
-
nullAllowed
public boolean nullAllowed()- Specified by:
nullAllowedin interfaceExtendedCollection<E>
-
maximumCapacity
public 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.
-
nullAdd
public boolean nullAdd()- Specified by:
nullAddin interfaceXAddingCollection<E>
-
ensureCapacity
- Specified by:
ensureCapacityin interfaceCapacityExtendable
-
ensureFreeCapacity
Description copied from interface:CapacityExtendableEnsures that the next minimalFreeCapacity elements can be actually added in a fast way, meaning for example no internal storage rebuild will be necessary.- Specified by:
ensureFreeCapacityin interfaceCapacityExtendable
-
currentCapacity
public long currentCapacity()Description copied from interface:CapacityExtendableReturns the current amount of elements this instance can hold before a storage rebuild becomes necessary.For carrier implementations that don't have a concept of storage rebuilding (like linked list for example) this method returns the same value as
CapacityCarrying.maximumCapacity().- Specified by:
currentCapacityin interfaceCapacityExtendable- Returns:
- the current capacity of this instance before a rebuild is required.
-
optimize
public long optimize()Description copied from interface:OptimizableCollectionOptimizes the internal storage of this collection and returns the storage size of the collection after the process is complete.- Specified by:
optimizein interfaceOptimizableCollection- Specified by:
optimizein interfaceXRemovingCollection<E>- Returns:
- the storage size of the collection after the optimzation.
-
accept
-
put
- Specified by:
putin interfaceXPuttingCollection<E>
-
nullPut
public boolean nullPut()- Specified by:
nullPutin interfaceXPuttingCollection<E>
-
fetch
- Specified by:
fetchin interfaceXProcessingCollection<E>
-
pinch
- Specified by:
pinchin interfaceXProcessingCollection<E>
-
retrieve
- Specified by:
retrievein interfaceXProcessingCollection<E>
-
retrieveBy
- Specified by:
retrieveByin interfaceXProcessingCollection<E>
-
removeDuplicates
- Specified by:
removeDuplicatesin interfaceXProcessingCollection<E>
-
removeBy
- Specified by:
removeByin interfaceXProcessingCollection<E>
-
moveTo
- Specified by:
moveToin interfaceXProcessingCollection<E>
-
process
- Specified by:
processin interfaceProcessable<E>
-
clear
public void clear()Description copied from interface:XRemovingCollectionClears all elements from the collection while leaving the capacity as it is.- Specified by:
clearin interfaceClearable- Specified by:
clearin interfaceXRemovingCollection<E>
-
truncate
public void truncate()Description copied from interface:XRemovingCollectionClears (and reinitializes if needed) this collection in the fastest possible way, i.e. by allocating a new and empty internal storage of default capacity. The collection will be empty after calling this method.- Specified by:
truncatein interfaceTruncateable- Specified by:
truncatein interfaceXRemovingCollection<E>
-
consolidate
public long consolidate()Description copied from interface:XRemovingCollectionConsolidates the internal storage of this collection by discarding all elements of the internal storage that have become obsolete or otherwise unneeded anymore. (e.g.WeakReferenceentries whose reference has been cleared).If this is not possible or not needed in the concrete implementation, this method does nothing and returns 0.
- Specified by:
consolidatein interfaceConsolidatableCollection- Specified by:
consolidatein interfaceXRemovingCollection<E>- Returns:
- the number of discarded entries.
-
nullRemove
public long nullRemove()- Specified by:
nullRemovein interfaceXRemovingCollection<E>
-
removeOne
- Specified by:
removeOnein interfaceXRemovingCollection<E>
-
remove
- Specified by:
removein interfaceXRemovingCollection<E>
-
removeAll
- Specified by:
removeAllin interfaceXRemovingCollection<E>
-
retainAll
- Specified by:
retainAllin interfaceXRemovingCollection<E>
-
removeDuplicates
public long removeDuplicates()- Specified by:
removeDuplicatesin interfaceXRemovingCollection<E>
-
addGet
- Specified by:
addGetin interfaceXAddGetSet<E>
-
deduplicate
- Specified by:
deduplicatein interfaceXAddGetSet<E>
-
putGet
- Specified by:
putGetin interfaceXPutGetSet<E>
-
replace
- Specified by:
replacein interfaceXPutGetSet<E>
-
immure
Description copied from interface:XGettingCollectionProvides an instance of an immutable collection type with equal behavior and data as this instance.If this instance already is of an immutable collection type, it returns itself.
- Specified by:
immurein interfaceXGettingCollection<E>- Specified by:
immurein interfaceXGettingSet<E>- Specified by:
immurein interfaceXProcessingSet<E>- Returns:
- an immutable copy of this collection instance.
-
putAll
- Specified by:
putAllin interfaceXCollection<E>- Specified by:
putAllin interfaceXPutGetCollection<E>- Specified by:
putAllin interfaceXPutGetSet<E>- Specified by:
putAllin interfaceXPuttingCollection<E>- Specified by:
putAllin interfaceXPuttingSet<E>- Specified by:
putAllin interfaceXSet<E>
-
putAll
- Specified by:
putAllin interfaceXCollection<E>- Specified by:
putAllin interfaceXPutGetCollection<E>- Specified by:
putAllin interfaceXPutGetSet<E>- Specified by:
putAllin interfaceXPuttingCollection<E>- Specified by:
putAllin interfaceXPuttingSet<E>- Specified by:
putAllin interfaceXSet<E>
-
putAll
- Specified by:
putAllin interfaceXCollection<E>- Specified by:
putAllin interfaceXPutGetCollection<E>- Specified by:
putAllin interfaceXPutGetSet<E>- Specified by:
putAllin interfaceXPuttingCollection<E>- Specified by:
putAllin interfaceXPuttingSet<E>- Specified by:
putAllin interfaceXSet<E>
-
addAll
- Specified by:
addAllin interfaceXAddGetCollection<E>- Specified by:
addAllin interfaceXAddGetSet<E>- Specified by:
addAllin interfaceXAddingCollection<E>- Specified by:
addAllin interfaceXAddingSet<E>- Specified by:
addAllin interfaceXCollection<E>- Specified by:
addAllin interfaceXPutGetCollection<E>- Specified by:
addAllin interfaceXPutGetSet<E>- Specified by:
addAllin interfaceXPuttingSet<E>- Specified by:
addAllin interfaceXSet<E>
-
addAll
- Specified by:
addAllin interfaceXAddGetCollection<E>- Specified by:
addAllin interfaceXAddGetSet<E>- Specified by:
addAllin interfaceXAddingCollection<E>- Specified by:
addAllin interfaceXAddingSet<E>- Specified by:
addAllin interfaceXCollection<E>- Specified by:
addAllin interfaceXPutGetCollection<E>- Specified by:
addAllin interfaceXPutGetSet<E>- Specified by:
addAllin interfaceXPuttingSet<E>- Specified by:
addAllin interfaceXSet<E>
-
addAll
- Specified by:
addAllin interfaceXAddGetCollection<E>- Specified by:
addAllin interfaceXAddGetSet<E>- Specified by:
addAllin interfaceXAddingCollection<E>- Specified by:
addAllin interfaceXAddingSet<E>- Specified by:
addAllin interfaceXCollection<E>- Specified by:
addAllin interfaceXPutGetCollection<E>- Specified by:
addAllin interfaceXPutGetSet<E>- Specified by:
addAllin interfaceXPuttingSet<E>- Specified by:
addAllin interfaceXSet<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 interfaceXAddGetCollection<E>- Specified by:
copyin interfaceXAddGetSet<E>- Specified by:
copyin interfaceXCollection<E>- Specified by:
copyin interfaceXGettingCollection<E>- Specified by:
copyin interfaceXGettingSet<E>- Specified by:
copyin interfaceXProcessingSet<E>- Specified by:
copyin interfaceXPutGetCollection<E>- Specified by:
copyin interfaceXPutGetSet<E>- Specified by:
copyin interfaceXSet<E>- Returns:
- a copy of this list
-
toString
-