Module inet.ipaddr

Class BaseDualIPv4v6Tries<T4 extends AddressTrie<IPv4Address>,​T6 extends AddressTrie<IPv6Address>>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<IPAddress>
    Direct Known Subclasses:
    DualIPv4v6AssociativeTries, DualIPv4v6Tries

    public abstract class BaseDualIPv4v6Tries<T4 extends AddressTrie<IPv4Address>,​T6 extends AddressTrie<IPv6Address>>
    extends java.lang.Object
    implements java.lang.Iterable<IPAddress>, java.io.Serializable, java.lang.Cloneable
    Contains a pair of IPv4 and IPv6 tries for a data structure that can have fast look-up and containment checks of both IPv4 and IPv6 addresses. For a tree that is either IPv4 or IPv6, you can just use #AddressTrie.
    Author:
    scfoley
    See Also:
    Serialized Form
    • Method Detail

      • getIPv4Trie

        public abstract T4 getIPv4Trie()
        returns the contained IPv4 trie
        Returns:
      • getIPv6Trie

        public abstract T6 getIPv6Trie()
        returns the contained IPv6 trie
        Returns:
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • toString

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

        public int size()
        Returns the number of elements in the tries. Only added nodes are counted. When zero is returned, isEmpty() returns true.
        Returns:
      • isEmpty

        public boolean isEmpty()
        Returns true if there are no added nodes within the two tries
      • add

        public boolean add​(IPAddress addr)
        Adds the given single address or prefix block subnet to one of the two tries.

        If the given address is not a single address nor prefix block, then this method throws IllegalArgumentException.

        If not a single address nor prefix block, the Partition class can be used to convert the address before calling this method. Given a subnet s of type E and a trie of type AddressTrie<E>, such as IPv4Address and IPv4AddressTrie, you can convert and add the spanning prefix blocks with Partition.partitionWithSpanningBlocks(s).predicateForEach(trie::add), or you can convert and add using a single max block size with Partition.partitionWithSingleBlockSize(s).predicateForEach(trie::add).

        Returns true if the prefix block or address was inserted, false if already in one of the two tries.

        Parameters:
        addr -
        Returns:
      • contains

        public boolean contains​(IPAddress addr)
        Returns whether the given address or prefix block subnet is in one of the two tries (as an added element).

        If the given address is not a single address nor prefix block, then this method throws IllegalArgumentException.

        If not a single address nor prefix block, the Partition class can be used to convert the address before calling this method. See AddressTrieOps.AddressTrieAddOps.add(Address) for more details.

        Returns true if the prefix block or address address exists already in one the two tries, false otherwise.

        Use getAddedNode(IPAddress) to get the node for the address rather than just checking for its existence.

        Parameters:
        addr -
        Returns:
      • remove

        public boolean remove​(IPAddress addr)
        Removes the given single address or prefix block subnet from the tries.

        Removing an element will not remove contained elements (nodes for contained blocks and addresses).

        If the given address is not a single address nor prefix block, then this method throws IllegalArgumentException.

        If not a single address nor prefix block, the Partition class can be used to convert the address before calling this method. See AddressTrieOps.AddressTrieAddOps.add(Address) for more details.

        Returns true if the prefix block or address was removed, false if not already in one of the two tries.

        You can also remove by calling getAddedNode(IPAddress) to get the node and then calling BinaryTreeNode.remove() on the node.

        When an address is removed, the corresponding node may remain in the trie if it remains a subnet block for two sub-nodes. If the corresponding node can be removed from the trie, it will be.

        Parameters:
        addr -
        Returns:
        See Also:
        removeElementsContainedBy(IPAddress)
      • elementContains

        public boolean elementContains​(IPAddress addr)
        Checks if a prefix block subnet or address in ones of the two tries contains the given subnet or address.

        If the given address is not a single address nor prefix block, then this method throws IllegalArgumentException.

        If not a single address nor prefix block, the Partition class can be used to convert the address before calling this method. See AddressTrieOps.AddressTrieAddOps.add(Address) for more details.

        Returns true if the subnet or address is contained by a trie element, false otherwise.

        To get all the containing addresses, use elementsContaining(IPAddress).

        Parameters:
        addr -
        Returns:
      • descendingIterator

        public java.util.Iterator<IPAddress> descendingIterator()
      • spliterator

        public java.util.Spliterator<IPAddress> spliterator()
        Specified by:
        spliterator in interface java.lang.Iterable<T4 extends AddressTrie<IPv4Address>>
      • descendingSpliterator

        public java.util.Spliterator<IPAddress> descendingSpliterator()
      • containingFirstIterator

        public abstract java.util.Iterator<? extends AddressTrie.TrieNode<? extends IPAddress>> containingFirstIterator​(boolean forwardSubNodeOrder)
      • containedFirstIterator

        public abstract java.util.Iterator<? extends AddressTrie.TrieNode<? extends IPAddress>> containedFirstIterator​(boolean forwardSubNodeOrder)
      • blockSizeNodeIterator

        public abstract java.util.Iterator<? extends AddressTrie.TrieNode<? extends IPAddress>> blockSizeNodeIterator​(boolean lowerSubNodeFirst)
      • nodeSpliterator

        public abstract java.util.Spliterator<? extends AddressTrie.TrieNode<? extends IPAddress>> nodeSpliterator​(boolean forward)