Class RadixTrie.TrieNode
- java.lang.Object
-
- org.opendaylight.lispflowmapping.inmemorydb.radixtrie.RadixTrie.TrieNode
-
- All Implemented Interfaces:
java.lang.Iterable<RadixTrie.TrieNode>
public class RadixTrie.TrieNode extends java.lang.Object implements java.lang.Iterable<RadixTrie.TrieNode>
Trie node definition.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
asIpPrefix()
Helper method that converts prefix and prefix length to dotted decimal, string, representation.boolean
comparePrefix(byte[] pref)
Compare node prefix with prefix.T
data()
void
erase()
Erase node.RadixTrie.TrieNode
findClosest(byte[] pref, int preflen, boolean virtual)
Finds closest prefix NOT the longest prefix match.int
firstDifferentBit(byte[] pref, int preflen)
Compares prefix to node's prefix and returns position of first different bit.RadixTrie.TrieNode
insert(byte[] pref, int preflen, int diffbit, T prefdata, byte[] closest)
Inserts node in trie near this node with prefix that has the first bit difference at diffbit.java.util.Iterator<RadixTrie.TrieNode>
iterator()
Retrieve iterator.RadixTrie.TrieNode
parentWithBitLessThan(int bitlen)
Find parent with bit less than given value.byte[]
prefix()
int
prefixLength()
void
resetData()
Clear node data.RadixTrie.TrieNode
sibling()
Return sibling node.java.lang.String
toString()
-
-
-
Method Detail
-
prefix
public byte[] prefix()
-
prefixLength
public int prefixLength()
-
data
public T data()
-
findClosest
public RadixTrie.TrieNode findClosest(byte[] pref, int preflen, boolean virtual)
Finds closest prefix NOT the longest prefix match.- Parameters:
pref
- Searched prefixpreflen
- Searched prefix lengthvirtual
- Include virtual nodes in search- Returns:
- The node found
-
firstDifferentBit
public int firstDifferentBit(byte[] pref, int preflen)
Compares prefix to node's prefix and returns position of first different bit.- Parameters:
pref
- Prefix to be compared.preflen
- Prefix length.- Returns:
- Position of first different bit.
-
parentWithBitLessThan
public RadixTrie.TrieNode parentWithBitLessThan(int bitlen)
Find parent with bit less than given value.- Parameters:
bitlen
- Bit value- Returns:
- Parent with bit less than given value
-
sibling
public RadixTrie.TrieNode sibling()
Return sibling node.- Returns:
- Sibling node, if there is a parent, else null
-
insert
public RadixTrie.TrieNode insert(byte[] pref, int preflen, int diffbit, T prefdata, byte[] closest)
Inserts node in trie near this node with prefix that has the first bit difference at diffbit.- Parameters:
pref
- Prefix to be inserted.preflen
- Prefix length of the prefix to be inserted.diffbit
- Bit index of the first different bit between prefix and current nodeprefdata
- Data to be stored together with the prefix- Returns:
- The trie node created or current node if it's an overwrite.
-
erase
public void erase()
Erase node.
-
resetData
public void resetData()
Clear node data.
-
comparePrefix
public boolean comparePrefix(byte[] pref)
Compare node prefix with prefix.- Parameters:
pref
- Prefix to be compared- Returns:
- True if prefixes are equal, false otherwise
-
asIpPrefix
public java.lang.String asIpPrefix()
Helper method that converts prefix and prefix length to dotted decimal, string, representation.- Returns:
- String representation of prefix.
-
iterator
public java.util.Iterator<RadixTrie.TrieNode> iterator()
Retrieve iterator.- Specified by:
iterator
in interfacejava.lang.Iterable<RadixTrie.TrieNode>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-