Package convex.core.data.prim
Class APrimitive
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.data.prim.APrimitive
-
Field Summary
Fields inherited from class convex.core.data.ACell
cachedRef, memorySize
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected long
Calculates the Memory Size for this Cell.abstract double
getRef
(int i) Gets a numbered child Ref from within this Cell.int
Gets the number of Refs contained within this Cell.boolean
Returns true if this Cell is in a canonical representation.final boolean
Returns true if this cell is a first class CVM Value allowable in the CVM state Sub-structural cells that are not themselves first class values should return false Records and types that are not permissible on the CVM should return false.final boolean
Returns true if this cell instance is a first class value, i.e.boolean
Determines if this Cell Represents an embedded object.abstract long
Converts this Cell to a canonical version.updateRefs
(IRefFunction func) Updates all Refs in this object using the given function.Methods inherited from class convex.core.data.ACell
attachMemorySize, attachRef, cachedEncoding, cachedHash, createEncoding, createRef, encode, encodeRaw, equals, equals, genericEquals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getMemorySize, getRef, getTag, getType, hashCode, toCVMString, toString, 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 convex.core.data.IWriteable
estimatedEncodingSize
-
Constructor Details
-
APrimitive
public APrimitive()
-
-
Method Details
-
isCanonical
public boolean isCanonical()Description copied from class:ACell
Returns true if this Cell is in a canonical representation. Non-canonical objects may be used on a temporary internal basis, they should be converted to canonical representations for general purpose use.- Specified by:
isCanonical
in classACell
- Returns:
- true if the object is in canonical format, false otherwise
-
isEmbedded
public boolean isEmbedded()Description copied from class:ACell
Determines if this Cell Represents an embedded object. Embedded objects are encoded directly into the encoding of the containing Cell (avoiding the need for a hashed reference). Subclasses should override this if they have a cheap O(1) way to determine if they are embedded or otherwise.- Overrides:
isEmbedded
in classACell
- Returns:
- true if Cell is embedded, false otherwise
-
isCVMValue
public final boolean isCVMValue()Description copied from class:ACell
Returns true if this cell is a first class CVM Value allowable in the CVM state Sub-structural cells that are not themselves first class values should return false Records and types that are not permissible on the CVM should return false. Pretty much everything else should return true. Note: CVM values might not be in a canonical format, e.g. temporary data structures- Specified by:
isCVMValue
in classACell
- Returns:
- true if the object is a CVM Value, false otherwise
-
isDataValue
public final boolean isDataValue()Description copied from class:ACell
Returns true if this cell instance is a first class value, i.e. not a component of a larger data structure Sub-structural cells that are not themselves first class values should return false Everything else should return true.- Specified by:
isDataValue
in classACell
- Returns:
- true if the object is a Value, false otherwise
-
calcMemorySize
protected long calcMemorySize()Description copied from class:ACell
Calculates the Memory Size for this Cell. Assumes not already calculated Requires any child Refs to be either direct or of persisted in store at minimum, or you might get a MissingDataException- Overrides:
calcMemorySize
in classACell
- Returns:
- Memory Size of this Cell
-
longValue
public abstract long longValue()- Returns:
- Java long value representing this primitive CVM value
-
doubleValue
public abstract double doubleValue()- Returns:
- Java double value representing this primitive CVM value
-
toCanonical
Description copied from class:ACell
Converts this Cell to a canonical version. Must return this Cell if already canonical, may be O(n) in size of value otherwise. Callers should usually use getCanonical(), which caches canonical instances once created- Specified by:
toCanonical
in classACell
- Returns:
- Canonical version of Cell
-
getRef
Description copied from class:ACell
Gets a numbered child Ref from within this Cell. WARNING: May need to convert to a canonical instance -
updateRefs
Description copied from class:ACell
Updates all Refs in this object using the given function. The function *must not* change the hash value of Refs, in order to ensure structural integrity of modified data structures. The implementation *should* re-attach any original encoding in order to prevent re-encoding or surplus hashing This is a building block for a very sneaky trick that enables use to do a lot of efficient operations on large trees of smart references. Must return the same object if no Refs are altered.- Overrides:
updateRefs
in classACell
- Parameters:
func
- Ref update function- Returns:
- Cell with updated Refs
-
getRefCount
public int getRefCount()Description copied from class:ACell
Gets the number of Refs contained within this Cell. This number is final / immutable for any given instance and is defined by the Cell encoding rules. Contained Refs may be either external or embedded.- Overrides:
getRefCount
in classACell
- Returns:
- The number of Refs in this Cell
-