Package convex.core.data
Class ASet<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>
- Type Parameters:
T- Type of set elements
- All Implemented Interfaces:
IAssociative<T,,CVMBool> IValidated,IWriteable,Iterable<T>,Collection<T>,Set<T>
- Direct Known Subclasses:
ADerivedSet,AHashSet
public abstract class ASet<T extends ACell>
extends ACollection<T>
implements Set<T>, IAssociative<T,CVMBool>
Abstract based class for sets.
Sets are immutable Smart Data Structures representing an unordered
collection of distinct values.
Iteration order is dependent on the Set implementation. In general, it
is bad practice to depend on any specific ordering for sets.
-
Field Summary
Fields inherited from class convex.core.data.ADataStructure
countFields inherited from class convex.core.data.ACell
cachedRef, memorySize -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAssociates a key with a value in this associative data structure.Adds an element to this collection, according to the natural semantics of the collectionconjAll(ACollection<? extends T> xs) Adds multiple elements to this data structure, in the natural manner defined by the general data structure type.abstract booleanTests if this Set contains a given valuefinal booleanabstract booleancontainsAll(ASet<?> b) Tests if this set contains all the elements of another setbooleancontainsKey(ACell key) Checks if the data structure contains the specified keydisjAll(ACollection<T> xs) Removes all elements from this set, returning a new set.empty()Returns an empty instance of the same Type as this data structure.Updates the set to exclude the given elementexcludeAll(ASet<T> elements) Updates the set to exclude all the given elements.get(long index) Gets the element at the specified element index in this valueGet the value associated with a given key.Get the value associated with a given key.getRefByHash(Hash hash) Gets the Ref in the Set for a given hash, or null if not foundfinal bytegetTag()Gets the tag byte for this cell.final ATypegetType()Gets the most specific known runtime Type for this Cell.getValueRef(ACell k) Gets the Ref in the Set for a given value, 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 valueintersectAll(ASet<T> xs) Returns the intersection of two setsbooleanTests if this set is a (non-strict) subset of another SetMaps a function over a collection, applying it to each element in turn.booleanprint(BlobBuilder sb, long limit) Prints this Object to a readable String Representation.slice(long start) Gets a slice of this Set from start to the endslice(long start, long end) Gets a slice of this SettoVector()Converts this collection to a canonical vector of elementsMethods inherited from class convex.core.data.ACollection
add, addAll, clear, containsAll, copyToArray, encode, iterator, remove, removeAll, retainAll, toArray, toArray, toCellArrayMethods inherited from class convex.core.data.ADataStructure
checkIndex, count, isDataValue, isEmpty, size, toCVMStringMethods inherited from class convex.core.data.ACountable
getElementRefMethods 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, toCanonical, toString, updateRefs, validate, validateCellMethods inherited from class convex.core.data.AObject
attachEncoding, print, printMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface convex.core.data.IWriteable
estimatedEncodingSize
-
Constructor Details
-
ASet
protected ASet(long count)
-
-
Method Details
-
getType
-
getTag
public final byte getTag()Description copied from class:ACellGets the tag byte for this cell. The tag byte is always equal to the first byte of the Cell's canonical Encoding, and is sufficient to distinguish how to read the rest of the encoding. -
include
-
exclude
-
includeAll
-
excludeAll
-
conjAll
Description copied from class:ADataStructureAdds 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.- Overrides:
conjAllin classADataStructure<T extends ACell>- Parameters:
xs- New elements to add- Returns:
- The updated data structure, or null if a failure occurred due to invalid element types
-
disjAll
Removes all elements from this set, returning a new set.- Parameters:
xs- Collection of elements to remove- Returns:
- Set with specified element(s) removed
-
toVector
Description copied from class:ACollectionConverts this collection to a canonical vector of elements- Specified by:
toVectorin classACollection<T extends ACell>- Returns:
- This collection coerced to a vector
-
map
Description copied from class:ACollectionMaps a function over a collection, applying it to each element in turn.- Specified by:
mapin classACollection<T extends ACell>- Type Parameters:
R- Type of element in resulting collection- Parameters:
mapper- Function to map over collection- Returns:
- Collection after function applied to each element
-
intersectAll
-
get
Description copied from class:ADataStructureGet the value associated with a given key.- Specified by:
getin classADataStructure<T extends ACell>- Parameters:
key- Associative key to look up- Returns:
- Value from collection, or a falsey value (null or false) if not found
-
get
Description copied from class:ADataStructureGet the value associated with a given key.- Specified by:
getin classADataStructure<T extends ACell>- Parameters:
key- Key to look up in data structurenotFound- Value to return if key is not found- Returns:
- Value from collection, or notFound value if not found
-
get
Description copied from class:ACountableGets the element at the specified element index in this value- Specified by:
getin classACountable<T extends ACell>- Parameters:
index- Index of element to get- Returns:
- Element at the specified index
-
contains
Tests if this Set contains a given value- Parameters:
o- Value to test for set membership- Returns:
- True if set contains value, false otherwise
-
contains
-
includeRef
-
conj
Description copied from class:ACollectionAdds an element to this collection, according to the natural semantics of the collection- Specified by:
conjin classACollection<T extends ACell>- Parameters:
a- Value to add, should be the element type of the data structure- Returns:
- The updated collection
-
assoc
Description copied from class:ADataStructureAssociates a key with a value in this associative data structure. May return null if the Key or Value is incompatible with the data structure.- Specified by:
associn classADataStructure<T extends ACell>- Parameters:
key- Associative keyvalue- Value to associate with key- Returns:
- Updates data structure, or null if data types are invalid
-
containsKey
Description copied from class:ADataStructureChecks if the data structure contains the specified key- Specified by:
containsKeyin classADataStructure<T extends ACell>- Parameters:
key- Associative key to look up- Returns:
- true if the data structure contains the key, false otherwise
-
empty
Description copied from class:ADataStructureReturns an empty instance of the same Type as this data structure.- Specified by:
emptyin classADataStructure<T extends ACell>- Returns:
- An empty data structure
-
getValueRef
-
getRefByHash
-
containsAll
Tests if this set contains all the elements of another set- Parameters:
b- Set to compare with- Returns:
- True if other set is completely contained within this set, false otherwise
-
isSubset
-
print
Description copied from class:AObjectPrints this Object to a readable String Representation. SECURITY: Must halt and return false in O(1) time when limit of printing is exceeded otherwise DoS attacks may be possible. -
slice
-
slice
-