Package convex.core.data
Class ACollection<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>
- 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>
-
Field Summary
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 TypeMethodDescriptionfinal boolean
final boolean
addAll
(Collection<? extends T> c) final void
clear()
abstract ACollection
<T> Adds an element to this collection, according to the natural semantics of the collectionabstract boolean
boolean
containsAll
(Collection<?> c) protected abstract <R> void
copyToArray
(R[] arr, int offset) Copies the elements of this collection in order to an array at the specified offsetabstract int
encode
(byte[] bs, int pos) Writes this Cell's encoding to a byte array, including a tag byte which will be written first.abstract AType
getType()
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.final boolean
final boolean
removeAll
(Collection<?> c) final boolean
retainAll
(Collection<?> c) Object[]
toArray()
<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, checkIndex, conjAll, containsKey, count, empty, get, get, isDataValue, isEmpty, size, toCVMString
Methods inherited from class convex.core.data.ACountable
get, getElementRef, slice, slice
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, getTag, hashCode, isCanonical, isCVMValue, isEmbedded, toCanonical, toString, updateRefs, validate, validateCell
Methods inherited from class convex.core.data.AObject
attachEncoding, print, print, print
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
equals, hashCode, isEmpty, parallelStream, removeIf, size, spliterator, stream, toArray
Methods inherited from interface convex.core.data.IWriteable
estimatedEncodingSize
-
Constructor Details
-
ACollection
protected ACollection(long count)
-
-
Method Details
-
getType
-
encode
public abstract int encode(byte[] bs, int pos) Description copied from class:ACell
Writes this Cell's encoding to a byte array, including a tag byte which will be written first. Cell must be canonical, or else an error may occur.- Specified by:
encode
in interfaceIWriteable
- Specified by:
encode
in 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:
contains
in interfaceCollection<T extends ACell>
-
iterator
-
add
- Specified by:
add
in interfaceCollection<T extends ACell>
-
remove
- Specified by:
remove
in interfaceCollection<T extends ACell>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T extends ACell>
-
addAll
- Specified by:
addAll
in interfaceCollection<T extends ACell>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<T extends ACell>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<T extends ACell>
-
clear
public final void clear()- Specified by:
clear
in interfaceCollection<T extends ACell>
-
toVector
-
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:
toArray
in interfaceCollection<T extends ACell>
-
toArray
- Specified by:
toArray
in interfaceCollection<T extends ACell>
-
conj
Adds an element to this collection, according to the natural semantics of the collection- Specified by:
conj
in classADataStructure<T extends ACell>
- Parameters:
x
- Value to add, should be the element type of the data structure- 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
-