Class NodeIterator.Cursor<E>

java.lang.Object
org.apache.sis.index.tree.NodeIterator.Cursor<E>
Enclosing class:
NodeIterator<E>

private static final class NodeIterator.Cursor<E> extends Object
A provider for arrays of elements of child nodes contained in a PointTreeNode. The starting point is PointTree.root. A new NodeIterator.Cursor instance is created for each level when the node at next level is itself a parent of at least two nodes (if there is only one child node, then this implementation takes a shortcut).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final long[]
    Masks for clearing the bits of all quadrants that do not intersect the search region on the left side.
    (package private) PointTreeNode
    The node for which to iterate over elements.
    The cursor that created this cursor, or null if none.
    (package private) long
    Bitmask of quadrants/octants on which to iterate.
    private final double[]
    (x,y,…) coordinates in the center of node node, followed by (Δx,Δy,…) sizes of the node node.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Cursor(double[] region)
    Creates a new cursor.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) final void
    Computes a bitmask of all quadrants/octants that intersect the search area.
    (package private) final NodeIterator.Cursor<E>
    Marks this NodeIterator.Cursor as available for recycling and returns its parent.
    (package private) final void
    moveDown(int q)
    Changes the state of this Cursor for getting elements in the specified quadrant/octant.
    (package private) final NodeIterator.Cursor<E>
    push(NodeIterator<E> it, int q)
    Creates a new Cursor for getting element arrays in the node quadrant/octant, without changing the state of this Cursor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • parent

      private NodeIterator.Cursor<E> parent
      The cursor that created this cursor, or null if none. If non-null, we will continue iteration with that parent after this NodeIterator.Cursor finished to return all element arrays.

      If this NodeIterator.Cursor instance is not used anymore (for now) and is made available for recycling, then this field is instead used for storing the next recyclable instance that may be used after this one, with no child-parent relationship.

    • node

      The node for which to iterate over elements. Only the quadrants/octants identified by the quadrants bitmask will be traversed.
    • quadrants

      long quadrants
      Bitmask of quadrants/octants on which to iterate. Quadrants/octants are iterated from rightmost bit to leftmost bit. Bits are cleared when the corresponding quadrant/octant become the current one. A value of 0 means that there are no more quadrants to iterate for the node.

      Note: we take "quadrant" name from QuadTree, but this algorithm can actually be used with more dimensions.

      See Also:
    • region

      private final double[] region
      (x,y,…) coordinates in the center of node node, followed by (Δx,Δy,…) sizes of the node node.
    • CLEAR_MASKS

      private static final long[] CLEAR_MASKS
      Masks for clearing the bits of all quadrants that do not intersect the search region on the left side. For example, for x dimension, this is the mask to apply if the xmin <= cx condition is false. In this example CLEAR_MASKS[0] clears the bits of all quadrants on the West side, which are quadrants 1, 3, 5, etc.

      The index in this array is the dimension in which the quadrant do not intersect the search region. The length of this array should be equal to PointTree.MAXIMUM_DIMENSIONS.

  • Constructor Details

  • Method Details

    • findIntersections

      final void findIntersections(NodeIterator<E> it)
      Computes a bitmask of all quadrants/octants that intersect the search area. This method must be invoked after region values changed.
      Parameters:
      it - the iterator which defines the area of interest.
    • push

      final NodeIterator.Cursor<E> push(NodeIterator<E> it, int q)
      Creates a new Cursor for getting element arrays in the node quadrant/octant, without changing the state of this Cursor. This method is invoked when there is a need to iterate in two more more children, in which case we cannot yet discard the information contained in this Cursor instance.

      Caller is responsible to update the node field after this method call and to invoke findIntersections(NodeIterator).

      Parameters:
      it - the enclosing iterator.
      q - the quadrant/octant in which to iterate.
      Returns:
      the cursor to use for getting element arrays in the specified quadrant/octant.
    • moveDown

      final void moveDown(int q)
      Changes the state of this Cursor for getting elements in the specified quadrant/octant. This method is invoked when there is no need to keep current Cursor information anymore, because there are no other quadrants/octants than the specified one in which to iterate.

      Caller is responsible to update the node field after this method call and to invoke findIntersections(NodeIterator).

      Parameters:
      q - the quadrant/octant in which to iterate.
    • getParentAndRecycle

      final NodeIterator.Cursor<E> getParentAndRecycle(NodeIterator<E> it)
      Marks this NodeIterator.Cursor as available for recycling and returns its parent.
      Parameters:
      it - the enclosing iterator.
      Returns:
      the parent of this Cursor, or null if none.