Package io.crums.util.mrkl
Class FreeLeafTree
java.lang.Object
io.crums.util.mrkl.Tree
io.crums.util.mrkl.FreeLeafTree
public class FreeLeafTree extends Tree
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
Constructors Constructor Description FreeLeafTree(byte[][] data, int leaves, java.lang.String algo)
Creates a new instance.FreeLeafTree(byte[][] data, int leaves, java.lang.String algo, boolean copy)
Creates a new instance. -
Method Summary
Methods inherited from class io.crums.util.mrkl.Tree
appendToStringDetail, getHashAlgo, hash, hashAlgoWidth, hashInternals, hashLeaves, hashUncommon, idx, isLeafWidthFixed, isOmniWidth, proof, root, toString, verify
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
FreeLeafTree
public FreeLeafTree(byte[][] data, int leaves, java.lang.String algo)Creates a new instance. Defensively copies.- Parameters:
data
- double array of length 2 x leaves - 1leaves
- the number of leaf nodesalgo
- the hashing algorithm
-
FreeLeafTree
public FreeLeafTree(byte[][] data, int leaves, java.lang.String algo, boolean copy)Creates a new instance.- Parameters:
data
- double array of length 2 x leaves - 1leaves
- the number of leaf nodesalgo
- the hashing algorithmcopy
- if true a defensive copy of data is used instead; if false, then data should not be modified
-
-
Method Details
-
data
public byte[] data(int level, int index)Description copied from class:Tree
Returns [a copy of] the data for the node at the specified coordinates.- Specified by:
data
in classTree
- See Also:
Node.data()
,#data(int, int, ByteBuffer)
-
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).
-