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 class
PersistentTrieSet.AbstractSetIterator<K>
Iterator skeleton that uses a fixed stack in depth.protected static class
PersistentTrieSet.AbstractSetNode<K>
(package private) static class
PersistentTrieSet.AbstractTransientTrieSet<K>
private static class
PersistentTrieSet.BitmapIndexedSetNode<K>
protected static class
PersistentTrieSet.CompactMixedSetNode<K>
protected static class
PersistentTrieSet.CompactSetNode<K>
private static class
PersistentTrieSet.HashCollisionSetNode<K>
protected static class
PersistentTrieSet.SetKeyIterator<K>
(package private) static class
PersistentTrieSet.TransientTrieSet<K>
private static class
PersistentTrieSet.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 int
cachedHashCode
private int
cachedSize
private static boolean
DEBUG
private static PersistentTrieSet.CompactSetNode
EMPTY_NODE
private static PersistentTrieSet
EMPTY_SET
private PersistentTrieSet.AbstractSetNode<K>
rootNode
private static long
serialVersionUID
-
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)
boolean
add(K key)
boolean
addAll(java.util.Collection<? extends K> c)
protected int[][]
arityCombinationsHistogram()
protected int[]
arityHistogram()
Set.Transient<K>
asTransient()
private boolean
checkHashCodeAndSize(int targetHash, int targetSize)
void
clear()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> c)
boolean
containsAllEquivalent(java.util.Collection<?> c, EqualityComparator<java.lang.Object> cmp)
boolean
containsEquivalent(java.lang.Object o, EqualityComparator<java.lang.Object> cmp)
boolean
equals(java.lang.Object other)
boolean
equivalent(java.lang.Object other, EqualityComparator<java.lang.Object> cmp)
K
get(java.lang.Object o)
K
getEquivalent(java.lang.Object o, EqualityComparator<java.lang.Object> cmp)
protected int
getNodeCount()
protected PersistentTrieSet.AbstractSetNode<K>
getRootNode()
int
hashCode()
private static <K> int
hashCode(PersistentTrieSet.AbstractSetNode<K> rootNode)
boolean
isEmpty()
boolean
isTransientSupported()
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)
void
printStatistics()
boolean
remove(java.lang.Object key)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> c)
int
size()
private static <K> int
size(PersistentTrieSet.AbstractSetNode<K> rootNode)
java.lang.Object[]
toArray()
<T> T[]
toArray(T[] a)
java.lang.String
toString()
static int
transformHashCode(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:
containsEquivalent
in interfaceSetEq<K>
-
getEquivalent
public K getEquivalent(java.lang.Object o, EqualityComparator<java.lang.Object> cmp)
- Specified by:
getEquivalent
in interfaceSetEq<K>
-
__insert
public Set.Immutable<K> __insert(K key)
- Specified by:
__insert
in interfaceSet.Immutable<K>
-
__insertEquivalent
public Set.Immutable<K> __insertEquivalent(K key, EqualityComparator<java.lang.Object> cmp)
- Specified by:
__insertEquivalent
in interfaceSetEq.Immutable<K>
-
__insertAll
public Set.Immutable<K> __insertAll(java.util.Set<? extends K> set)
- Specified by:
__insertAll
in interfaceSet.Immutable<K>
-
__insertAllEquivalent
public Set.Immutable<K> __insertAllEquivalent(java.util.Set<? extends K> set, EqualityComparator<java.lang.Object> cmp)
- Specified by:
__insertAllEquivalent
in interfaceSetEq.Immutable<K>
-
__remove
public Set.Immutable<K> __remove(K key)
- Specified by:
__remove
in interfaceSet.Immutable<K>
-
__removeEquivalent
public Set.Immutable<K> __removeEquivalent(K key, EqualityComparator<java.lang.Object> cmp)
- Specified by:
__removeEquivalent
in interfaceSetEq.Immutable<K>
-
__removeAll
public Set.Immutable<K> __removeAll(java.util.Set<? extends K> set)
- Specified by:
__removeAll
in interfaceSet.Immutable<K>
-
__removeAllEquivalent
public Set.Immutable<K> __removeAllEquivalent(java.util.Set<? extends K> set, EqualityComparator<java.lang.Object> cmp)
- Specified by:
__removeAllEquivalent
in interfaceSetEq.Immutable<K>
-
__retainAll
public Set.Immutable<K> __retainAll(java.util.Set<? extends K> set)
- Specified by:
__retainAll
in interfaceSet.Immutable<K>
-
__retainAllEquivalent
public Set.Immutable<K> __retainAllEquivalent(Set.Transient<? extends K> transientSet, EqualityComparator<java.lang.Object> cmp)
- Specified by:
__retainAllEquivalent
in 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:
containsAll
in interfacejava.util.Collection<K>
- Specified by:
containsAll
in interfaceSet<K>
- Specified by:
containsAll
in interfacejava.util.Set<K>
-
containsAllEquivalent
public boolean containsAllEquivalent(java.util.Collection<?> c, EqualityComparator<java.lang.Object> cmp)
- Specified by:
containsAllEquivalent
in 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:
keyIterator
in 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:
equivalent
in interfaceSetEq<K>
-
hashCode
public int hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isTransientSupported
public boolean isTransientSupported()
- Specified by:
isTransientSupported
in interfaceSet.Immutable<K>
-
asTransient
public Set.Transient<K> asTransient()
- Specified by:
asTransient
in 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()
-
-