public final class UUIDTrie extends 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.
Constructor and Description |
---|
UUIDTrie() |
Modifier and Type | Method and Description |
---|---|
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. |
Iterator<byte[]> |
iterator() |
boolean |
remove(byte[] uuid)
Remove an element and return true if it was present, and
false
|
byte[] |
serialize() |
public void clear()
public boolean add(byte[] uuid)
Add a new element returning true
if it wasn't already in the set
and false
otherwise.
uuid
- public boolean find(byte[] uuid)
Return true
if the given element is in the set and false
otherwise.
uuid
- public boolean remove(byte[] uuid)
Remove an element and return true
if it was present, and
false
uuid
- public byte[] serialize()
public void deserialize(byte[] data)
public Iterator<byte[]> iterator()
Copyright © 2015. All rights reserved.