anthill.types
Interface ReturnPath

All Known Implementing Classes:
ArrayReturnPath

public interface ReturnPath

This interface represents an utility data structure that can be used by ants to obtain information about the return path to the requestor nest.

Version:
$Revision: 1.2 $
Author:
Alberto Montresor

Method Summary
 boolean addLast(AntView view, NestId id)
          Adds a new element to the path.
 int capacity()
          Return the current length of the path.
 void init(AntView view)
          Initializes this data structure.
 NestId removeLast(AntView view)
          Removes the last element of the path and returns it to the invoker.
 int size()
          Return the current length of the path.
 

Method Detail

init

public void init(AntView view)
Initializes this data structure. This method must be invoked at most once, for example in the init method of ants.
The implementation may make use of view, for example using local resource storages to maintain information about the return path.

Parameters:
view - the current view associated to the ant using this data structure

addLast

public boolean addLast(AntView view,
                       NestId id)
Adds a new element to the path. Returns true if this element already belongs to the path, false otherwise. Depending on the implementation, if the element already belongs to the path, the element may be added again or not.
The implementation may make use of view, for example using local resource storages to maintain information about the return path.

Parameters:
view - the current view associated to the ant using this data structure

removeLast

public NestId removeLast(AntView view)
Removes the last element of the path and returns it to the invoker. Returns null if there are no more elements in the path.
The implementation may make use of view, for example using local resource storages to maintain information about the return path.

Parameters:
view - the current view associated to the ant using this data structure

size

public int size()
Return the current length of the path.


capacity

public int capacity()
Return the current length of the path.