Class S2ShapeIndex.EdgeAllocator

java.lang.Object
com.google.common.geometry.S2ShapeIndex.EdgeAllocator
Enclosing class:
S2ShapeIndex

private static final class S2ShapeIndex.EdgeAllocator extends Object
This class provides temporary storage for new ClippedEdges that are created during indexing. It is essentially a stack-based object pool, where edges are allocated as the recursion goes down the first time, put back in the pool as recursion come back up, and reused when recursion goes back down another branch of the S2Cell tree.
  • Field Details

  • Constructor Details

    • EdgeAllocator

      public EdgeAllocator(int maxEdges)
  • Method Details

    • create

      public S2ShapeIndex.ClippedEdge create()
      Returns an edge.
    • size

      public int size()
      Returns the number of allocated edges. Before a thread calls create(), this method should be called to assess the size of the stack, and after all created edges are no longer needed, call reset(int) with the previous size.
    • reset

      public void reset(int size)
      Returns all edges after 'size' to the object pool to be reused by another thread.