Package ucar.nc2.dt.ugrid.rtree
Class IntProcedureEntriesStack
- java.lang.Object
-
- ucar.nc2.dt.ugrid.rtree.IntProcedureEntriesStack
-
- All Implemented Interfaces:
IntProcedure
public class IntProcedureEntriesStack extends Object implements IntProcedure
TheIntProcedureEntriesStackclass provides an implementation of anIntProcedureand records node id's from its execution in a stack.
Simply pass an instance of this class to an rtree search and access the retrieved node indices withpeek(),peek(int), andpop(). These indices are returned asIntegerobjects.
-
-
Constructor Summary
Constructors Constructor Description IntProcedureEntriesStack()Initializes an emptyIntProcedureEntriesStack.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanclear()Removes all of the elements from this stack (optional operation).Stringdump()Builds a dump of the indexed values within this stackbooleanexecute(int id)Caches the id passed from the calling method to the stack.Integerpeek()Retrieves the value of the top-most item on this stackIntegerpeek(int index)Retrieves the value of the top-most item on this stackList<Integer>peekAll()Retrieves anIntegerlist of all items on this stackIntegerpop()Removes theIntegervalue from the top of this stackList<Integer>popAll()Removes all items from this stack.voidpush(int value)Pushes the given value to the top of this stackintsize()Returns the number of elements in this stack.
-
-
-
Method Detail
-
execute
public boolean execute(int id)
Caches the id passed from the calling method to the stack. This method is utilized primarily for the purpose of rtree searches and is typically not invoked explicitly- Specified by:
executein interfaceIntProcedure- Parameters:
id- a node id (from an RTree)- Returns:
trueif execution succeeds, otherwisefalse
-
pop
public Integer pop()
Removes theIntegervalue from the top of this stack- Returns:
- the value removed from the top of this stack or
nullif there are no values on the stack
-
popAll
public List<Integer> popAll()
Removes all items from this stack. Useclear()instead, if the values returned by this methods invokation are not going to be used.- Returns:
- a copy of the values removed from this stack in an
Integerlist
-
push
public void push(int value)
Pushes the given value to the top of this stack- Parameters:
value- anInteger
-
peek
public Integer peek()
Retrieves the value of the top-most item on this stack- Returns:
- an
Integervalue, ornullif no values have been pushed to this stack
-
peek
public Integer peek(int index) throws IndexOutOfBoundsException
Retrieves the value of the top-most item on this stack- Parameters:
index- an integer index- Returns:
- an
Integervalue - Throws:
IndexOutOfBoundsException- if the indices is out of range (indices < 0 || indices >= size())
-
peekAll
public List<Integer> peekAll()
Retrieves anIntegerlist of all items on this stack- Returns:
- a copy of the internal
Integerlist
-
size
public int size()
Returns the number of elements in this stack. If this stack contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.- Returns:
- the number of elements in this stack.
-
clear
public boolean clear()
Removes all of the elements from this stack (optional operation). This list will be empty after this call returns (unless it throws an exception).- Returns:
trueon success; otherwisefalse
-
dump
public String dump()
Builds a dump of the indexed values within this stack- Returns:
- a
String
-
-