Package convex.core.data
Class ACountable<E extends ACell>
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.data.ACountable<E>
- Type Parameters:
E
- Type of element that is counted
- All Implemented Interfaces:
IValidated
,IWriteable
- Direct Known Subclasses:
ABlob
,ADataStructure
,AString
Abstract base class for Countable objects.
Countable values support a count of elements and the ability to get by an element index.
-
Field Summary
Fields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract long
count()
Returns the number of elements in this data structureabstract ACountable<E>
empty()
Returns a canonical, singleton empty instance of the same type as this Countable value.abstract E
get
(long index) Gets the element at the specified element index in this collectiongetElementRef
(long index) Gets a Ref to the element at the specified element index in this collectionboolean
isEmpty()
Checks if this data structure is empty, i.e.int
size()
Gets the size of this data structure as an int.slice
(long start) Gets a slice of this data structure from start to the endabstract ACountable<E>
slice
(long start, long end) Gets a slice of this data structureMethods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, encode, encodeRaw, equals, equals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, getRefCount, getTag, getType, hashCode, isCanonical, isCompletelyEncoded, isCVMValue, isEmbedded, mark, mark, toCanonical, toCVMString, toString, updateRefs, validate, validateCell, write
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 convex.core.data.IWriteable
estimatedEncodingSize
-
Constructor Details
-
ACountable
public ACountable()
-
-
Method Details
-
count
public abstract long count()Returns the number of elements in this data structure- Returns:
- Number of elements in this collection.
-
get
Gets the element at the specified element index in this collection- Parameters:
index
- Index of element to get- Returns:
- Element at the specified index
-
getElementRef
Gets a Ref to the element at the specified element index in this collection- Parameters:
index
- Index of element to get- Returns:
- Element at the specified index
-
isEmpty
public boolean isEmpty()Checks if this data structure is empty, i.e. has a count of zero elements.- Returns:
- true if this data structure is empty, false otherwise
-
empty
Returns a canonical, singleton empty instance of the same type as this Countable value.- Returns:
- An empty Countable value
-
size
public int size()Gets the size of this data structure as an int. Returns Integer.MAX_SIZE if the count is larger than can fit in an int. If this might be a problem, use count() instead.- Returns:
- Number of elements in this collection.
-
slice
Gets a slice of this data structure- Parameters:
start
- Start index (inclusive)end
- end index (exclusive)- Returns:
- Slice of data structure, or null if invalid slice
-
slice
Gets a slice of this data structure from start to the end- Parameters:
start
- Start index (inclusive)- Returns:
- Slice of data structure, or null if invalid slice
-