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 sub-elements and the ability to get by 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 E
get(long index)
Gets the element at the specified index in this collectiongetElementRef(long index)
Gets a Ref to the element at the specified 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.Methods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, encode, encodeRaw, equals, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, getRefCount, getTag, getType, hashCode, isCanonical, isCVMValue, isEmbedded, mark, mark, toCanonical, toString, updateRefs, validate, validateCell, write
Methods inherited from class convex.core.data.AObject
attachEncoding, 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 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 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
-
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.
-