Class RadixTrie.TrieNode

java.lang.Object
org.opendaylight.lispflowmapping.inmemorydb.radixtrie.RadixTrie.TrieNode
All Implemented Interfaces:
Iterable<RadixTrie<T>.TrieNode>
Enclosing class:
RadixTrie<T>

public class RadixTrie.TrieNode extends Object implements Iterable<RadixTrie<T>.TrieNode>
Trie node definition.
  • Method Details

    • prefix

      public byte[] prefix()
    • prefixLength

      public int prefixLength()
    • data

      public T data()
    • findClosest

      public RadixTrie<T>.TrieNode findClosest(byte[] pref, int preflen, boolean virtual)
      Finds closest prefix NOT the longest prefix match.
      Parameters:
      pref - Searched prefix
      preflen - Searched prefix length
      virtual - 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<T>.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<T>.TrieNode sibling()
      Return sibling node.
      Returns:
      Sibling node, if there is a parent, else null
    • insert

      public RadixTrie<T>.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 node
      prefdata - 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 String asIpPrefix()
      Helper method that converts prefix and prefix length to dotted decimal, string, representation.
      Returns:
      String representation of prefix.
    • iterator

      public Iterator<RadixTrie<T>.TrieNode> iterator()
      Retrieve iterator.
      Specified by:
      iterator in interface Iterable<RadixTrie<T>.TrieNode>
    • toString

      public String toString()
      Overrides:
      toString in class Object