Class NodeBase

  • Direct Known Subclasses:
    Node, Root

    public abstract class NodeBase
    extends Object
    The base class for nodes in a Bintree.
    Version:
    1.7
    • Field Detail

      • items

        protected List items
      • subnode

        protected Node[] subnode
        subnodes are numbered as follows: 0 | 1
    • Constructor Detail

      • NodeBase

        public NodeBase()
    • Method Detail

      • getSubnodeIndex

        public static int getSubnodeIndex​(Interval interval,
                                          double centre)
        Returns the index of the subnode that wholely contains the given interval. If none does, returns -1.
      • getItems

        public List getItems()
      • add

        public void add​(Object item)
      • addAllItems

        public List addAllItems​(List items)
      • isSearchMatch

        protected abstract boolean isSearchMatch​(Interval interval)
      • addAllItemsFromOverlapping

        public void addAllItemsFromOverlapping​(Interval interval,
                                               Collection resultItems)
        Adds items in the tree which potentially overlap the query interval to the given collection. If the query interval is null, add all items in the tree.
        Parameters:
        interval - a query interval, or null
        resultItems - the candidate items found
      • remove

        public boolean remove​(Interval itemInterval,
                              Object item)
        Removes a single item from this subtree.
        Parameters:
        itemInterval - the envelope containing the item
        item - the item to remove
        Returns:
        true if the item was found and removed
      • isPrunable

        public boolean isPrunable()
      • hasChildren

        public boolean hasChildren()
      • hasItems

        public boolean hasItems()