Package com.google.common.geometry
Class S2ShapeIndex.EdgeAllocator
- java.lang.Object
-
- com.google.common.geometry.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.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<S2ShapeIndex.ClippedEdge>
edges
private int
size
-
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.
-
-
-
Field Detail
-
size
private int size
-
edges
private final java.util.List<S2ShapeIndex.ClippedEdge> edges
-
-
Method Detail
-
create
public S2ShapeIndex.ClippedEdge create()
Returns an edge.
-
size
public int size()
Returns the number of allocated edges. Before a thread callscreate()
, this method should be called to assess the size of the stack, and after all created edges are no longer needed, callreset(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.
-
-