Package convex.core.data
Class StringTree
- All Implemented Interfaces:
IValidated,IWriteable,CharSequence,Comparable<AString>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intstatic intstatic intstatic intFields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AStringappend(char charValue)protected voidappendToStringBuffer(StringBuilder sb, int start, int length)protected static intcalcChildCount(int length, int shift)protected static intcalcShift(int length)charcharAt(int index)static StringTreeintencodeRaw(byte[] bs, int pos)Writes this Cell's encoding to a byte array, excluding the tag byteintEstimate the encoded data size for this Cell.getRef(int i)Gets a numbered child Ref from within this Cell.intGets the number of Refs contained within this Cell.booleanReturns true if this Cell is in a canonical format for message writing.booleanReturns true if this object represents a first class CVM Value.static StringTreeread(int length, ByteBuffer bb)subSequence(int start, int end)Converts this Cell to its canonical version.updateRefs(IRefFunction func)Updates all Refs in this object using the given function.voidValidates the local structure and invariants of this cell.Methods inherited from class convex.core.data.AString
compareTo, count, empty, encode, get, getElementRef, getTag, getType, length, print, toStringMethods inherited from class convex.core.data.ACountable
isEmpty, sizeMethods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, equals, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, hashCode, isEmbedded, validate, writeMethods inherited from class convex.core.data.AObject
attachEncoding, printMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Field Details
-
MINIMUM_LENGTH
public static final int MINIMUM_LENGTH- See Also:
- Constant Field Values
-
BASE_SHIFT
public static final int BASE_SHIFT- See Also:
- Constant Field Values
-
BIT_SHIFT_PER_LEVEL
public static final int BIT_SHIFT_PER_LEVEL- See Also:
- Constant Field Values
-
FANOUT
public static final int FANOUT- See Also:
- Constant Field Values
-
-
Constructor Details
-
StringTree
-
-
Method Details
-
calcShift
protected static int calcShift(int length) -
create
-
charAt
public char charAt(int index) -
subSequence
- Specified by:
subSequencein interfaceCharSequence- Specified by:
subSequencein classAString
-
validateCell
Description copied from class:ACellValidates the local structure and invariants of this cell. Called by validate() super implementation. Should validate directly contained data, but should not validate all other structure of this cell. In particular, should not traverse potentially missing child Refs.- Specified by:
validateCellin classACell- Throws:
InvalidDataException- If the Cell is invalid
-
encodeRaw
public int encodeRaw(byte[] bs, int pos)Description copied from class:ACellWrites this Cell's encoding to a byte array, excluding the tag byte -
read
- Throws:
BadFormatException
-
calcChildCount
protected static int calcChildCount(int length, int shift) -
estimatedEncodingSize
public int estimatedEncodingSize()Description copied from interface:IWriteableEstimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is likely to contain the entire object when represented in binary format, including the tag byte.- Returns:
- The estimated size for the binary representation of this object.
-
isCanonical
public boolean isCanonical()Description copied from class:ACellReturns true if this Cell is in a canonical format for message writing. Reading or writing a non-canonical value should be considered illegal, but non-canonical objects may be used on a temporary internal basis.- Specified by:
isCanonicalin classACell- Returns:
- true if the object is in canonical format, false otherwise
-
isCVMValue
public final boolean isCVMValue()Description copied from class:ACellReturns true if this object represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false. CVM values might not be in a canonical format, e.g. temporary data structures- Specified by:
isCVMValuein classACell- Returns:
- true if the object is a CVM Value, false otherwise
-
getRefCount
public int getRefCount()Description copied from class:ACellGets the number of Refs contained within this Cell. This number is final / immutable for any given instance. Contained Refs may be either external or embedded.- Specified by:
getRefCountin classACell- Returns:
- The number of Refs in this Cell
-
getRef
Description copied from class:ACellGets a numbered child Ref from within this Cell. -
updateRefs
Description copied from class:ACellUpdates 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. 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:
updateRefsin classACell- Parameters:
func- Ref update function- Returns:
- Cell with updated Refs
-
appendToStringBuffer
- Specified by:
appendToStringBufferin classAString
-
append
-
toCanonical
Description copied from class:ACellConverts this Cell to its canonical version. Returns this if already canonical- Specified by:
toCanonicalin classACell- Returns:
- Canonical version of Cell
-