org.hypergraphdb.atom.impl
Class UUIDTrie

java.lang.Object
  extended by org.hypergraphdb.atom.impl.UUIDTrie

public final class UUIDTrie
extends java.lang.Object

An implementation of a trie for storing UUIDs. This is used to efficiently represent persistent handle sets.

Elements of this trie are assumed to be of fixed 16 byte length. The trie is implemented with a 16 length alphabet (each byte is split into two parts of 4 bits). Thus the depth of the resulting tree structure is 32. Terminal elements are the ones that reach that depth.

This implementation also supports a compact and efficient serialization of the whole structure for storage purposes.

Since this is intended as an implementation of a HGAtomSet, which is statically typed for persistent handles, no checks are made for nulls or correct byte array sizes.

Purging of branches is implemented during lookup. If the lookup procedure reaches a death branch (i.e. one with all its children pointers set to null), that branch is removed.

Author:
Borislav Iordanov

Constructor Summary
UUIDTrie()
           
 
Method Summary
 boolean add(byte[] uuid)
          Add a new element returning true if it wasn't already in the set and false otherwise.
 void clear()
           
 UUIDTrie clone()
           
 void deserialize(byte[] data)
           
 boolean find(byte[] uuid)
          Return true if the given element is in the set and false otherwise.
 java.util.Iterator<byte[]> iterator()
           
 boolean remove(byte[] uuid)
          Remove an element and return true if it was present, and false
 byte[] serialize()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UUIDTrie

public UUIDTrie()
Method Detail

clear

public void clear()

clone

public UUIDTrie clone()
Overrides:
clone in class java.lang.Object

add

public boolean add(byte[] uuid)

Add a new element returning true if it wasn't already in the set and false otherwise.

Parameters:
uuid -
Returns:

find

public boolean find(byte[] uuid)

Return true if the given element is in the set and false otherwise.

Parameters:
uuid -
Returns:

remove

public boolean remove(byte[] uuid)

Remove an element and return true if it was present, and false

Parameters:
uuid -
Returns:

serialize

public byte[] serialize()

deserialize

public void deserialize(byte[] data)

iterator

public java.util.Iterator<byte[]> iterator()