Class S2ShapeIndex.EdgeAllocator

  • Enclosing class:
    S2ShapeIndex

    private static final class S2ShapeIndex.EdgeAllocator
    extends java.lang.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.
    • Constructor Summary

      Constructors 
      Constructor Description
      EdgeAllocator​(int maxEdges)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      S2ShapeIndex.ClippedEdge create()
      Returns an edge.
      void reset​(int size)
      Returns all edges after 'size' to the object pool to be reused by another thread.
      int size()
      Returns the number of allocated edges.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EdgeAllocator

        public EdgeAllocator​(int maxEdges)
    • Method Detail

      • 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.