Class BinaryTree
java.lang.Object
org.apache.commons.compress.archivers.zip.BinaryTree
Binary tree of positive values.
- Since:
- 1.7
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLeaf
(int node, int path, int depth, int value) Adds a leaf to the tree.(package private) static BinaryTree
decode
(InputStream inputStream, int totalNumberOfValues) Decodes the packed binary tree from the specified stream.int
Reads a value from the specified bit stream.
-
Field Details
-
UNDEFINED
private static final int UNDEFINEDValue in the array indicating an undefined node- See Also:
-
NODE
private static final int NODEValue in the array indicating a non leaf node- See Also:
-
tree
private final int[] treeThe array representing the binary tree. The root is at index 0, the left children are at 2*i+1 and the right children at 2*i+2.
-
-
Constructor Details
-
BinaryTree
public BinaryTree(int depth)
-
-
Method Details
-
addLeaf
public void addLeaf(int node, int path, int depth, int value) Adds a leaf to the tree.- Parameters:
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)
-
read
Reads a value from the specified bit stream.- Parameters:
stream
-- Returns:
- the value decoded, or -1 if the end of the stream is reached
- Throws:
IOException
-
decode
Decodes the packed binary tree from the specified stream.- Throws:
IOException
-