Class FreeLeafTree
java.lang.Object
io.crums.util.mrkl.Tree
io.crums.util.mrkl.FreeLeafTree
A
Tree allowing variable length leaves. Note although less efficient,
this layout allows larger in-memory fixed-width trees than FixedLeafTree.-
Field Summary
Fields inherited from class io.crums.util.mrkl.Tree
BRANCH_PAD, LEAF_PAD -
Constructor Summary
ConstructorsConstructorDescriptionFreeLeafTree(byte[][] data, int leaves, String algo) Creates a new instance.FreeLeafTree(byte[][] data, int leaves, String algo, boolean copy) Creates a new instance. -
Method Summary
Methods inherited from class io.crums.util.mrkl.Tree
appendToStringDetail, getHashAlgo, hash, hashAlgoWidth, hashInternals, hashInternals, hashLeaves, hashLeaves, hashUncommon, hashUncommon, idx, isLeafWidthFixed, isOmniWidth, proof, root, toString
-
Constructor Details
-
FreeLeafTree
Creates a new instance. Defensively copies.- Parameters:
data- double array of length 2 xleaves- 1leaves- the number of leaf nodesalgo- the hashing algorithm
-
FreeLeafTree
Creates a new instance.- Parameters:
data- double array of length 2 xleaves- 1leaves- the number of leaf nodesalgo- the hashing algorithmcopy- iftrue, then a defensive copy ofdatais made; iffalse, thendatashould not be modified
-
-
Method Details
-
data
public byte[] data(int level, int index) Description copied from class:TreeReturns [a copy of] the data for the node at the specified coordinates. For internal nodes, this is just the node's hash, which is computed from the hash of its child nodes; for leaf nodes, the node's data may generally be anything, but more often than not it's the hash of a source object. -
data
public final byte[] data(int serialIndex) -
leafWidth
public int leafWidth()Returns -1 signifying variable width. Note, it may coincidentally happen that all the leaves are fixed width. If you've specifically arranged for this, but are for some reason using this class instead of FixedLeafTree, then override this method to return its fixed value.
Returns the leaf width in bytes if fixed; -1, otherwise (variable).
-