|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--anthill.nestor.LocalTrail
Class LocalTrail
is the implementation of Trail
to be used during off-line simulations. Programmers are enabled to specify
the maximum number of associations (ant identifier, previous nest identifier)
which can be stored in a LocalTrail
object, or the maximum duration
of such an associations in a LocalTrail
object, or both.
Assocations which exceed the maximum capacity or are older than the maximum
duration are discarded from this LocalTrail
.
Inner Class Summary | |
protected class |
LocalTrail.Pair
The Pair class is an inner class used to link objects in the hash table in a list. |
Field Summary | |
protected LocalTrail.Pair |
head
Head of the list connecting the pairs; pairs will be removed here |
protected java.util.HashMap |
map
Hash table mapping ant identifiers to the nest from which the ant has arrived. |
protected LocalTrail.Pair |
tail
Tail of the list connecting the pairs; pairs will be added here |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
LocalTrail(int maxsize,
int maxtime,
int interval)
Instantiate a new Trail object by setting the maximum number of pair (ant id, source) which may be contained in it. |
Method Summary | |
boolean |
add(AntId id,
NestId source)
Add a pair (id, source) to the trail object containing the host. |
void |
end()
Close the thread associated to this trail. |
NestId |
lookup(AntId id)
Lookup this LocalTrail object in order to obtain the
identifier of the nest from which the specified
ant arrived. |
void |
run()
Periodically scans the linked list of pairs in order to remove staled pairs (ant id, nest id). |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.HashMap map
protected LocalTrail.Pair head
protected LocalTrail.Pair tail
Constructor Detail |
public LocalTrail(int maxsize, int maxtime, int interval)
maxsize
- maximum number of pairs (ant id, source) which may
be contained in this Trail
object. If zero, the
number of pairs is not limited.maxtime
- maximum time (in milliseconds) of permanence
of a pair in this Trail
object. If zero, the
maximum time of permanence is not limited.interval
- polling time for obsolete pair removalsMethod Detail |
public boolean add(AntId id, NestId source)
add
in interface Trail
public NestId lookup(AntId id)
LocalTrail
object in order to obtain the
identifier of the nest from which the specified
ant arrived. The pair associating the ant
identifier to the source nest is removed from
both the hash table and the linked list.lookup
in interface Trail
public void run()
run
in class java.lang.Thread
public void end()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |