getnbr

Class: B

(legend)

Operand Stack Heap Condition Codes
  • Initial (operands):
    value - which neighbor
  • Final (return values):
    value - the address of the neighbor
N/A

1 = success

0 = fail

Description

Get the address of the neighbor specified by the value on top of the stack. All neighbors are stored in a list. The value specifies which position in the list to get. The value must be between 0 and numnbrs-1.

Note: There is no synchronization between a call to numnbrs and subsequent calls to getnbr, nor between two calls to getnbr. Since the neighbor list is dynamic, calling getnbr may fail or may return the same neighbor using two different indices. Failure is indicated by the condition code being set to 0.

The suggested way of iterating through all neighbors is to take a snapshot of the neighbor list by calling numnbrs, then immediately calling getnbr to push the entire list onto the stack.



This page was last updated on December 7, 2005 3:50 AM.
This work is supported by the ONR MURI Project CONTESSA and the NSF under grant number CCR-9970939.