class BinaryTree
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static int |
NODE
Value in the array indicating a non leaf node
|
private int[] |
tree
The array representing the binary tree.
|
private static int |
UNDEFINED
Value in the array indicating an undefined node
|
Constructor and Description |
---|
BinaryTree(int depth) |
Modifier and Type | Method and Description |
---|---|
void |
addLeaf(int node,
int path,
int depth,
int value)
Adds a leaf to the tree.
|
(package private) static BinaryTree |
decode(java.io.InputStream in,
int totalNumberOfValues)
Decodes the packed binary tree from the specified stream.
|
int |
read(BitStream stream)
Reads a value from the specified bit stream.
|
private static final int UNDEFINED
private static final int NODE
private final int[] tree
public void addLeaf(int node, int path, int depth, int value)
node
- the index of the node where the path is appendedpath
- the path to the leaf (bits are parsed from the right to the left)depth
- the number of nodes in the pathvalue
- the value of the leaf (must be positive)public int read(BitStream stream) throws java.io.IOException
stream
- java.io.IOException
static BinaryTree decode(java.io.InputStream in, int totalNumberOfValues) throws java.io.IOException
java.io.IOException