Package io.usethesource.capsule.core
Class PersistentTrieSet<K>
- java.lang.Object
-
- io.usethesource.capsule.core.PersistentTrieSet<K>
-
- All Implemented Interfaces:
Set<K>,Set.Immutable<K>,SetEq<K>,SetEq.Immutable<K>,java.io.Serializable,java.lang.Iterable<K>,java.util.Collection<K>,java.util.Set<K>
public class PersistentTrieSet<K> extends java.lang.Object implements Set.Immutable<K>, java.io.Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPersistentTrieSet.AbstractSetIterator<K>Iterator skeleton that uses a fixed stack in depth.protected static classPersistentTrieSet.AbstractSetNode<K>(package private) static classPersistentTrieSet.AbstractTransientTrieSet<K>private static classPersistentTrieSet.BitmapIndexedSetNode<K>protected static classPersistentTrieSet.CompactMixedSetNode<K>protected static classPersistentTrieSet.CompactSetNode<K>private static classPersistentTrieSet.HashCollisionSetNode<K>protected static classPersistentTrieSet.SetKeyIterator<K>(package private) static classPersistentTrieSet.TransientTrieSet<K>private static classPersistentTrieSet.TrieSetNodeIterator<K>Iterator that first iterates over inlined-values and then continues depth first recursively.-
Nested classes/interfaces inherited from interface io.usethesource.capsule.Set
Set.Immutable<K>, Set.Transient<K>
-
Nested classes/interfaces inherited from interface io.usethesource.capsule.SetEq
SetEq.Immutable<K>, SetEq.Transient<K>
-
-
Field Summary
Fields Modifier and Type Field Description private intcachedHashCodeprivate intcachedSizeprivate static booleanDEBUGprivate static PersistentTrieSet.CompactSetNodeEMPTY_NODEprivate static PersistentTrieSetEMPTY_SETprivate PersistentTrieSet.AbstractSetNode<K>rootNodeprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description PersistentTrieSet(PersistentTrieSet.AbstractSetNode<K> rootNode, int cachedHashCode, int cachedSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Set.Immutable<K>__insert(K key)Set.Immutable<K>__insertAll(java.util.Set<? extends K> set)Set.Immutable<K>__insertAllEquivalent(java.util.Set<? extends K> set, EqualityComparator<java.lang.Object> cmp)Set.Immutable<K>__insertEquivalent(K key, EqualityComparator<java.lang.Object> cmp)Set.Immutable<K>__remove(K key)Set.Immutable<K>__removeAll(java.util.Set<? extends K> set)Set.Immutable<K>__removeAllEquivalent(java.util.Set<? extends K> set, EqualityComparator<java.lang.Object> cmp)Set.Immutable<K>__removeEquivalent(K key, EqualityComparator<java.lang.Object> cmp)Set.Immutable<K>__retainAll(java.util.Set<? extends K> set)Set.Immutable<K>__retainAllEquivalent(Set.Transient<? extends K> transientSet, EqualityComparator<java.lang.Object> cmp)booleanadd(K key)booleanaddAll(java.util.Collection<? extends K> c)protected int[][]arityCombinationsHistogram()protected int[]arityHistogram()Set.Transient<K>asTransient()private booleancheckHashCodeAndSize(int targetHash, int targetSize)voidclear()booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> c)booleancontainsAllEquivalent(java.util.Collection<?> c, EqualityComparator<java.lang.Object> cmp)booleancontainsEquivalent(java.lang.Object o, EqualityComparator<java.lang.Object> cmp)booleanequals(java.lang.Object other)booleanequivalent(java.lang.Object other, EqualityComparator<java.lang.Object> cmp)Kget(java.lang.Object o)KgetEquivalent(java.lang.Object o, EqualityComparator<java.lang.Object> cmp)protected intgetNodeCount()protected PersistentTrieSet.AbstractSetNode<K>getRootNode()inthashCode()private static <K> inthashCode(PersistentTrieSet.AbstractSetNode<K> rootNode)booleanisEmpty()booleanisTransientSupported()java.util.Iterator<K>iterator()java.util.Iterator<K>keyIterator()protected java.util.Iterator<PersistentTrieSet.AbstractSetNode<K>>nodeIterator()static <K> Set.Immutable<K>of()static <K> Set.Immutable<K>of(K key0)static <K> Set.Immutable<K>of(K... keys)static <K> Set.Immutable<K>of(K key0, K key1)voidprintStatistics()booleanremove(java.lang.Object key)booleanremoveAll(java.util.Collection<?> c)booleanretainAll(java.util.Collection<?> c)intsize()private static <K> intsize(PersistentTrieSet.AbstractSetNode<K> rootNode)java.lang.Object[]toArray()<T> T[]toArray(T[] a)java.lang.StringtoString()static inttransformHashCode(int hash)static <K> Set.Transient<K>transientOf()static <K> Set.Transient<K>transientOf(K... keys)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.usethesource.capsule.Set.Immutable
intersect, subtract, union
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
EMPTY_NODE
private static final PersistentTrieSet.CompactSetNode EMPTY_NODE
-
EMPTY_SET
private static final PersistentTrieSet EMPTY_SET
-
DEBUG
private static final boolean DEBUG
- See Also:
- Constant Field Values
-
rootNode
private final PersistentTrieSet.AbstractSetNode<K> rootNode
-
cachedHashCode
private final int cachedHashCode
-
cachedSize
private final int cachedSize
-
-
Constructor Detail
-
PersistentTrieSet
PersistentTrieSet(PersistentTrieSet.AbstractSetNode<K> rootNode, int cachedHashCode, int cachedSize)
-
-
Method Detail
-
of
public static final <K> Set.Immutable<K> of()
-
of
public static final <K> Set.Immutable<K> of(K key0)
-
of
public static final <K> Set.Immutable<K> of(K key0, K key1)
-
of
public static final <K> Set.Immutable<K> of(K... keys)
-
transientOf
public static final <K> Set.Transient<K> transientOf()
-
transientOf
public static final <K> Set.Transient<K> transientOf(K... keys)
-
hashCode
private static <K> int hashCode(PersistentTrieSet.AbstractSetNode<K> rootNode)
-
size
private static <K> int size(PersistentTrieSet.AbstractSetNode<K> rootNode)
-
checkHashCodeAndSize
private boolean checkHashCodeAndSize(int targetHash, int targetSize)
-
transformHashCode
public static final int transformHashCode(int hash)
-
contains
public boolean contains(java.lang.Object o)
-
containsEquivalent
public boolean containsEquivalent(java.lang.Object o, EqualityComparator<java.lang.Object> cmp)- Specified by:
containsEquivalentin interfaceSetEq<K>
-
getEquivalent
public K getEquivalent(java.lang.Object o, EqualityComparator<java.lang.Object> cmp)
- Specified by:
getEquivalentin interfaceSetEq<K>
-
__insert
public Set.Immutable<K> __insert(K key)
- Specified by:
__insertin interfaceSet.Immutable<K>
-
__insertEquivalent
public Set.Immutable<K> __insertEquivalent(K key, EqualityComparator<java.lang.Object> cmp)
- Specified by:
__insertEquivalentin interfaceSetEq.Immutable<K>
-
__insertAll
public Set.Immutable<K> __insertAll(java.util.Set<? extends K> set)
- Specified by:
__insertAllin interfaceSet.Immutable<K>
-
__insertAllEquivalent
public Set.Immutable<K> __insertAllEquivalent(java.util.Set<? extends K> set, EqualityComparator<java.lang.Object> cmp)
- Specified by:
__insertAllEquivalentin interfaceSetEq.Immutable<K>
-
__remove
public Set.Immutable<K> __remove(K key)
- Specified by:
__removein interfaceSet.Immutable<K>
-
__removeEquivalent
public Set.Immutable<K> __removeEquivalent(K key, EqualityComparator<java.lang.Object> cmp)
- Specified by:
__removeEquivalentin interfaceSetEq.Immutable<K>
-
__removeAll
public Set.Immutable<K> __removeAll(java.util.Set<? extends K> set)
- Specified by:
__removeAllin interfaceSet.Immutable<K>
-
__removeAllEquivalent
public Set.Immutable<K> __removeAllEquivalent(java.util.Set<? extends K> set, EqualityComparator<java.lang.Object> cmp)
- Specified by:
__removeAllEquivalentin interfaceSetEq.Immutable<K>
-
__retainAll
public Set.Immutable<K> __retainAll(java.util.Set<? extends K> set)
- Specified by:
__retainAllin interfaceSet.Immutable<K>
-
__retainAllEquivalent
public Set.Immutable<K> __retainAllEquivalent(Set.Transient<? extends K> transientSet, EqualityComparator<java.lang.Object> cmp)
- Specified by:
__retainAllEquivalentin interfaceSetEq.Immutable<K>
-
add
public boolean add(K key)
-
addAll
public boolean addAll(java.util.Collection<? extends K> c)
-
clear
public void clear()
-
remove
public boolean remove(java.lang.Object key)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
- Specified by:
containsAllin interfacejava.util.Collection<K>- Specified by:
containsAllin interfaceSet<K>- Specified by:
containsAllin interfacejava.util.Set<K>
-
containsAllEquivalent
public boolean containsAllEquivalent(java.util.Collection<?> c, EqualityComparator<java.lang.Object> cmp)- Specified by:
containsAllEquivalentin interfaceSetEq<K>
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
iterator
public java.util.Iterator<K> iterator()
-
keyIterator
public java.util.Iterator<K> keyIterator()
- Specified by:
keyIteratorin interfaceSet<K>
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
equals
public boolean equals(java.lang.Object other)
-
equivalent
public boolean equivalent(java.lang.Object other, EqualityComparator<java.lang.Object> cmp)- Specified by:
equivalentin interfaceSetEq<K>
-
hashCode
public int hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isTransientSupported
public boolean isTransientSupported()
- Specified by:
isTransientSupportedin interfaceSet.Immutable<K>
-
asTransient
public Set.Transient<K> asTransient()
- Specified by:
asTransientin interfaceSet.Immutable<K>
-
getRootNode
protected PersistentTrieSet.AbstractSetNode<K> getRootNode()
-
nodeIterator
protected java.util.Iterator<PersistentTrieSet.AbstractSetNode<K>> nodeIterator()
-
getNodeCount
protected int getNodeCount()
-
arityCombinationsHistogram
protected int[][] arityCombinationsHistogram()
-
arityHistogram
protected int[] arityHistogram()
-
printStatistics
public void printStatistics()
-
-