Class RadixTrie.TrieNode

    • 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()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • 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 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.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 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 java.lang.String asIpPrefix()
        Helper method that converts prefix and prefix length to dotted decimal, string, representation.
        Returns:
        String representation of prefix.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object