Package convex.core.data
Class AHashSet<T extends ACell>
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.data.ACountable<E>
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 int
protected static int
protected static int
protected static int
protected static int
Fields inherited from class convex.core.data.ADataStructure
count
Fields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplySelf(int setOp)
conj(R a)
Adds an element to this collection, according to the natural semantics of the collectionconjAll(ACollection<R> 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<T> valueRef)
Get the value associated with a given key.Gets the Value in the set for the given hash, or null if not foundinclude(R a)
Updates the set to include the given elementincludeAll(ASet<R> 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 int
reverseOp(int setOp)
Object[]
toArray()
Converts this Cell to its canonical version.protected abstract void
validateWithPrefix(Hash prefix, int digit, int shift)
Validates the set with a given hex prefix.Methods inherited from class convex.core.data.ASet
assoc, contains, containsAll, containsKey, empty, equals, equals, get, get, getRefByHash, getTag, getType, getValueRef, isSubset, map, print, 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
count, isEmpty, size
Methods inherited from class convex.core.data.ACountable
getElementRef
Methods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, encodeRaw, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, getRefCount, hashCode, isCanonical, isCVMValue, isEmbedded, mark, mark, toString, updateRefs, validate, validateCell, write
Methods inherited from class convex.core.data.AObject
attachEncoding, 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:
- Constant Field Values
-
OP_INTERSECTION
protected static final int OP_INTERSECTION- See Also:
- Constant Field Values
-
OP_DIFF_LEFT
protected static final int OP_DIFF_LEFT- See Also:
- Constant Field Values
-
OP_DIFF_RIGHT
protected static final int OP_DIFF_RIGHT- See Also:
- Constant Field Values
-
MAX_SHIFT
protected static final int MAX_SHIFT- See Also:
- Constant Field Values
-
-
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
Description copied from class:ASet
Returns the intersection of two sets- Specified by:
intersectAll
in classASet<T extends ACell>
- Parameters:
elements
- Set to intersect with- Returns:
- Intersection of the two sets
-
excludeAll
Description copied from class:ASet
Updates the set to exclude all the given elements.- Specified by:
excludeAll
in classASet<T extends ACell>
- Parameters:
elements
- Elements to exclude- Returns:
- Updated set
-
toCanonical
Description copied from class:ACell
Converts this Cell to its canonical version. Returns this Cell if already canonical.- 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
Description copied from class:ASet
Removes all elements from this set, returning a new set. -
excludeRef
-
includeRef
Description copied from class:ASet
Adds a value to this set using a Ref to the value- Specified by:
includeRef
in classASet<T extends ACell>
- Parameters:
ref
- Ref to value to include- Returns:
- Updated set
-
conj
Description copied from class:ACollection
Adds an element to this collection, according to the natural semantics of the collection -
exclude
Description copied from class:ASet
Updates the set to exclude the given element -
include
Description copied from class:ASet
Updates the set to include the given element -
validateWithPrefix
protected abstract void validateWithPrefix(Hash prefix, int digit, int shift) throws InvalidDataExceptionValidates 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
Description copied from class:ADataStructure
Get the value associated with a given key. -
getByHash
Gets the Value in the set for the given hash, or null if not found- Parameters:
hash
- Hash of value to check in set- Returns:
- The Value for the given Hash if found, null otherwise.
-
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
Description copied from class:ASet
Tests if this Set contains a given value
-