public interface TreeBuilder<N extends TreeNode>
To add new leaves to the tree, methods add(TreeNode) or
add(TreeNode...) can be used.
Note that this interface does not describe how leaves are processed and how binary tree is built. Several different implementations can exist to support different types of trees. For example some implementation can sort leaves and by doing so break the order of the leaves.
| Modifier and Type | Method and Description |
|---|---|
void |
add(N... nodes)
Adds a new list of leaves to the binary tree.
|
void |
add(N node)
Adds a new leaf to the binary tree.
|
void |
add(N node,
IdentityMetadata metadata)
Adds a new leaf with its metadata to the binary tree.
|
N |
build()
Builds the binary tree and returns the root hash of the tree.
|
long |
calculateHeight(N node)
Calculates the binary tree height if new leaf would be added.
|
long |
calculateHeight(N node,
IdentityMetadata metadata)
Calculates the binary tree height if new leaf with metadata would be added.
|
void add(N node) throws KSIException
node - a leaf to add to the tree, must not be null.KSIExceptionvoid add(N node, IdentityMetadata metadata) throws HashException, KSIException
add(TreeNode, IdentityMetadata) may not support IdentityMetadata and may
throw an UnsupportedOperationException.node - leaf node to be added, must not be null.metadata - node's metadata, must not be nullHashExceptionKSIExceptionUnsupportedOperationException - if operation is not supportedlong calculateHeight(N node) throws KSIException
node - a leaf to be added to the tree, must not be null.KSIExceptionlong calculateHeight(N node, IdentityMetadata metadata) throws HashException, KSIException
calculateHeight(TreeNode, IdentityMetadata) may not support IdentityMetadata and may
throw an UnsupportedOperationException.node - a leaf to be added to the tree, must not be null.metadata - node's metadata, must not be nullHashExceptionKSIExceptionUnsupportedOperationException - if operation is not supportedvoid add(N... nodes) throws KSIException
nodes - a list of leaves to be added to the tree, must not be null.KSIExceptionN build() throws KSIException
TreeNode.getLeftChildNode() and/or TreeNode.getRightChildNode() methods can be used for tree traversal.KSIExceptionCopyright © 2024 Guardtime. All rights reserved.