public class AvlTreeMarshaller<E> extends Object implements Marshaller<AvlTree<E>>
Constructor and Description |
---|
AvlTreeMarshaller(Comparator<E> comparator)
Creates a new instance of AvlTreeMarshaller with the default key
Marshaller which uses Java Serialization.
|
AvlTreeMarshaller(Comparator<E> comparator,
Marshaller<E> keyMarshaller)
Creates a new instance of AvlTreeMarshaller with a custom key
Marshaller.
|
Modifier and Type | Method and Description |
---|---|
AvlTree<E> |
deserialize(byte[] data)
Creates an AVLTree from given bytes of data.
|
LinkedAvlNode<E> |
readTree(DataInputStream in,
LinkedAvlNode[] nodes)
Reads the data from given InputStream and creates the LinkedAvlNodes to
form the tree node = [size] [data-length] [data] [index] [child-marker]
[node] [child-marker] [node].
|
byte[] |
serialize(AvlTree<E> tree)
Marshals the given tree to bytes
|
public AvlTreeMarshaller(Comparator<E> comparator, Marshaller<E> keyMarshaller)
comparator
- Comparator to be used for key comparisionkeyMarshaller
- marshaller for keyspublic AvlTreeMarshaller(Comparator<E> comparator)
comparator
- Comparator to be used for key comparisionpublic byte[] serialize(AvlTree<E> tree)
serialize
in interface Marshaller<AvlTree<E>>
tree
- the tree to be marshalledpublic AvlTree<E> deserialize(byte[] data) throws IOException
deserialize
in interface Marshaller<AvlTree<E>>
data
- byte array to be converted into AVLTreeIOException
public LinkedAvlNode<E> readTree(DataInputStream in, LinkedAvlNode[] nodes) throws IOException
in
- the input stream to deserialize fromnodes
- the deserialized nodesIOException
- on failures to deserialize or read from the streamCopyright © 2003–2020 The Apache Software Foundation. All rights reserved.