Package ucar.nc2.dt.ugrid.rtree
Class IntProcedureEntriesStack
java.lang.Object
ucar.nc2.dt.ugrid.rtree.IntProcedureEntriesStack
- All Implemented Interfaces:
IntProcedure
The
Simply pass an instance of this class to an rtree search and access the retrieved node indices with
IntProcedureEntriesStack class provides an implementation of an IntProcedure and
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 with
peek(),
peek(int),
and pop(). These indices are returned as Integer objects.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanclear()Removes all of the elements from this stack (optional operation).dump()Builds a dump of the indexed values within this stackbooleanexecute(int id) Caches the id passed from the calling method to the stack.peek()Retrieves the value of the top-most item on this stackpeek(int index) Retrieves the value of the top-most item on this stackpeekAll()Retrieves anIntegerlist of all items on this stackpop()Removes theIntegervalue from the top of this stackpopAll()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.
-
Constructor Details
-
IntProcedureEntriesStack
public IntProcedureEntriesStack()Initializes an emptyIntProcedureEntriesStack.
-
-
Method Details
-
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
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
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
Retrieves the value of the top-most item on this stack- Returns:
- an
Integervalue, ornullif no values have been pushed to this stack
-
peek
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
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
Builds a dump of the indexed values within this stack- Returns:
- a
String
-