Package convex.core.data
Class AHashSet<T extends ACell>
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.data.ACountable<T>
convex.core.data.ADataStructure<T>
convex.core.data.ACollection<T>
convex.core.data.ASet<T>
convex.core.data.AHashSet<T>
- All Implemented Interfaces:
IAssociative<T,
,CVMBool> IValidated
,IWriteable
,Iterable<T>
,Collection<T>
,Set<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
protected static final int
protected static final int
protected static final int
protected static final int
Fields inherited from class convex.core.data.ADataStructure
count
Fields inherited from class convex.core.data.ACell
cachedRef, memorySize
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplySelf
(int setOp) Adds an element to this collection, according to the natural semantics of the collectionconjAll
(ACollection<? extends T> elements) Adds multiple elements to this data structure, in the natural manner defined by the general data structure type.boolean
Tests if this Set contains a given valueabstract boolean
containsHash
(Hash hash) Tests if this Set contains a given hashdisjAll
(ACollection<T> b) Removes all elements from this set, returning a new set.Updates the set to exclude the given elementexcludeAll
(ASet<T> elements) Updates the set to exclude all the given elements.excludeRef
(Ref<?> valueRef) final CVMBool
Get the value associated with a given key.Gets the Value in the set for the given hash, or null if not foundUpdates the set to include the given elementincludeAll
(ASet<? extends T> elements) Updates the set to include all the given elements.includeRef
(Ref<T> ref) Adds a value to this set using a Ref to the valueincludeRef
(Ref<T> e, int i) intersectAll
(ASet<T> elements) Returns the intersection of two setsprotected final int
reverseOp
(int setOp) Object[]
toArray()
Converts this Cell to a canonical version.protected abstract void
validateWithPrefix
(Hash prefix, int digit, int position) Validates the set with a given hex prefix.Methods inherited from class convex.core.data.ASet
assoc, contains, containsAll, containsKey, empty, get, get, getRefByHash, getTag, getType, getValueRef, isSubset, map, print, slice, slice, toVector
Methods inherited from class convex.core.data.ACollection
add, addAll, clear, containsAll, copyToArray, encode, iterator, remove, removeAll, retainAll, toArray, toCellArray
Methods inherited from class convex.core.data.ADataStructure
checkIndex, count, isDataValue, isEmpty, size, toCVMString
Methods inherited from class convex.core.data.ACountable
getElementRef
Methods inherited from class convex.core.data.ACell
attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createEncoding, createRef, encodeRaw, equals, equals, genericEquals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getMemorySize, getRef, getRef, getRefCount, hashCode, isCanonical, isCVMValue, isEmbedded, toString, updateRefs, validate, validateCell
Methods inherited from class convex.core.data.AObject
attachEncoding, print, print
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface convex.core.data.IWriteable
estimatedEncodingSize
-
Field Details
-
OP_UNION
protected static final int OP_UNION- See Also:
-
OP_INTERSECTION
protected static final int OP_INTERSECTION- See Also:
-
OP_DIFF_LEFT
protected static final int OP_DIFF_LEFT- See Also:
-
OP_DIFF_RIGHT
protected static final int OP_DIFF_RIGHT- See Also:
-
MAX_SHIFT
protected static final int MAX_SHIFT- See Also:
-
-
Constructor Details
-
AHashSet
protected AHashSet(long count)
-
-
Method Details
-
mergeWith
-
mergeWith
-
includeAll
Description copied from class:ASet
Updates the set to include all the given elements. Can be used to implement union of sets- Specified by:
includeAll
in classASet<T extends ACell>
- Parameters:
elements
- Elements to include- Returns:
- Updated set
-
reverseOp
protected final int reverseOp(int setOp) -
applyOp
-
applySelf
-
intersectAll
-
excludeAll
-
toCanonical
Description copied from class:ACell
Converts this Cell to a canonical version. Must return this Cell if already canonical, may be O(n) in size of value otherwise. Callers should usually use getCanonical(), which caches canonical instances once created- Specified by:
toCanonical
in classACell
- Returns:
- Canonical version of Cell
-
conjAll
Description copied from class:ADataStructure
Adds multiple elements to this data structure, in the natural manner defined by the general data structure type. e.g. append at the end of a vector. This may be more efficient than using 'conj' for individual items. -
disjAll
-
excludeRef
-
includeRef
-
conj
Description copied from class:ACollection
Adds an element to this collection, according to the natural semantics of the collection -
exclude
-
include
-
validateWithPrefix
protected abstract void validateWithPrefix(Hash prefix, int digit, int position) throws InvalidDataException Validates the set with a given hex prefix. This is necessary to ensure that child maps are valid, in particular have the correct shift level and that all hashes start with the correct prefix of hex characters.- Parameters:
prefix
- Hash for earlier prefix valuesdigit
- Hex digit expected at position [shift]- Throws:
InvalidDataException
-
toArray
-
get
-
getByHash
-
includeRef
-
containsHash
Tests if this Set contains a given hash- Parameters:
hash
- Hash to test for set membership- Returns:
- True if set contains value for given hash, false otherwise
-
contains
-