Top Description Fields Constructors Methods
org.apache.commons.compress.archivers.zip

pack-priv final Class BinaryTree

extends Object
Class Inheritance
Imports
java.io.EOFException, .IOException, .InputStream, java.util.Arrays, org.apache.commons.compress.utils.IOUtils

Binary tree of positive values.
Since
1.7

Field Summary

Modifier and TypeField and Description
private static final int
NODE

Value in the array indicating a non leaf node

private final int[]
tree

The array representing the binary tree.

private static final int
UNDEFINED

Value in the array indicating an undefined node

Constructor Summary

AccessConstructor and Description
pack-priv
BinaryTree(final int depth)

Method Summary

Modifier and TypeMethod and Description
public void
addLeaf(final int
the index of the node where the path is appended
node
,
final int
the path to the leaf (bits are parsed from the right to the left)
path
,
final int
the number of nodes in the path
depth
,
final int
the value of the leaf (must be positive)
value
)

Adds a leaf to the tree.

pack-priv static BinaryTree
decode(final InputStream inputStream, final int totalNumberOfValues)

Decodes the packed binary tree from the specified stream.

public int

Returns:

the value decoded, or -1 if the end of the stream is reached
read
(final BitStream stream)

Reads a value from the specified bit stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NODEback to summary
private static final int NODE

Value in the array indicating a non leaf node

treeback to summary
private final int[] tree

The 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.

UNDEFINEDback to summary
private static final int UNDEFINED

Value in the array indicating an undefined node

Constructor Detail

BinaryTreeback to summary
pack-priv BinaryTree(final int depth)

Method Detail

addLeafback to summary
public void addLeaf(final int node, final int path, final int depth, final int value)

Adds a leaf to the tree.

Parameters
node:int

the index of the node where the path is appended

path:int

the path to the leaf (bits are parsed from the right to the left)

depth:int

the number of nodes in the path

value:int

the value of the leaf (must be positive)

decodeback to summary
pack-priv static BinaryTree decode(final InputStream inputStream, final int totalNumberOfValues) throws IOException

Decodes the packed binary tree from the specified stream.

readback to summary
public int read(final BitStream stream) throws IOException

Reads a value from the specified bit stream.

Returns:int

the value decoded, or -1 if the end of the stream is reached

Exceptions
IOException:
on error.