Package convex.core.data
Class ACollection<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>
- Type Parameters:
T- Type of elements in this collection
- All Implemented Interfaces:
IValidated,IWriteable,Iterable<T>,Collection<T>
public abstract class ACollection<T extends ACell>
extends ADataStructure<T>
implements Collection<T>
Abstract base class for Persistent Merkle Collections
A Collection is a data structure that contains zero or more elements. Possible collection subtypes include:
- Sequential collections (Lists, Vectors)
- Sets (with unique elements)
-
Field Summary
Fields inherited from class convex.core.data.ADataStructure
countFields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends T> c)voidclear()abstract <R extends ACell>
ACollection<R>conj(R x)Adds an element to this collection, according to the natural semantics of the collectionabstract booleanbooleancontainsAll(Collection<?> c)protected abstract <R> voidcopyToArray(R[] arr, int offset)Copies the elements of this collection in order to an array at the specified offsetabstract intencode(byte[] bs, int pos)Writes this Cell's encoding to a byte array, including a tag byte which will be written firstabstract ATypegetType()Gets the most specific known runtime Type for this Cell.iterator()abstract <R extends ACell>
ACollection<R>Maps a function over a collection, applying it to each element in turn.booleanbooleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)<V> V[]toArray(V[] a)ACell[]Converts this collection to a new Cell arraytoVector()Converts this collection to a canonical vector of elementsMethods inherited from class convex.core.data.ADataStructure
assoc, conjAll, containsKey, count, empty, get, get, isEmpty, sizeMethods inherited from class convex.core.data.ACountable
get, getElementRefMethods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, encodeRaw, equals, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, getRefCount, getTag, hashCode, isCanonical, isCVMValue, isEmbedded, toCanonical, toString, updateRefs, validate, validateCell, writeMethods 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
equals, hashCode, isEmpty, parallelStream, removeIf, size, spliterator, stream, toArray, toArrayMethods inherited from interface convex.core.data.IWriteable
estimatedEncodingSize
-
Constructor Details
-
ACollection
protected ACollection(long count)
-
-
Method Details
-
getType
Description copied from class:ACellGets the most specific known runtime Type for this Cell. -
encode
public abstract int encode(byte[] bs, int pos)Description copied from class:ACellWrites this Cell's encoding to a byte array, including a tag byte which will be written first- Specified by:
encodein interfaceIWriteable- Specified by:
encodein classACell- Parameters:
bs- A byte array to which to write the encodingpos- The offset into the byte array- Returns:
- New position after writing
-
contains
- Specified by:
containsin interfaceCollection<T extends ACell>
-
iterator
-
add
- Specified by:
addin interfaceCollection<T extends ACell>
-
remove
- Specified by:
removein interfaceCollection<T extends ACell>
-
containsAll
- Specified by:
containsAllin interfaceCollection<T extends ACell>
-
addAll
- Specified by:
addAllin interfaceCollection<T extends ACell>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T extends ACell>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T extends ACell>
-
clear
public final void clear()- Specified by:
clearin interfaceCollection<T extends ACell>
-
toVector
Converts this collection to a canonical vector of elements- Returns:
- This collection coerced to a vector
-
copyToArray
protected abstract <R> void copyToArray(R[] arr, int offset)Copies the elements of this collection in order to an array at the specified offset- Type Parameters:
R- Type of array elements required- Parameters:
arr-offset-
-
toCellArray
Converts this collection to a new Cell array- Returns:
- A new cell array containing the elements of this sequence
-
toArray
public <V> V[] toArray(V[] a)- Specified by:
toArrayin interfaceCollection<T extends ACell>
-
conj
Adds an element to this collection, according to the natural semantics of the collection- Specified by:
conjin classADataStructure<T extends ACell>- Type Parameters:
R- Type of Value added- Parameters:
x- Value to add- Returns:
- The updated collection
-
map
Maps a function over a collection, applying it to each element in turn.- Type Parameters:
R- Type of element in resulting collection- Parameters:
mapper- Function to map over collection- Returns:
- Collection after function applied to each element
-