|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gishur.core.Sweep
The basic class for sweep algorithms. Each instance holds an event- and a
status-structure. To implement a certain sweep algorithm it is recommended
to derive a new class from this one and to override its processEvent(gishur.core.SweepEvent)
-method. After the creation of an event-structure and a status-structure,
SweepEvents
can be generated and the algorithm can be
started with execute()
.
As an alternative, a SweepListener
can be defined with
setSweepListener(gishur.core.SweepListener)
which is then responsible for the processing of
any events, instead of overriding the processEvent(gishur.core.SweepEvent)
-method.
In opposite to GUI-events, SweepEvents
can be processed only once
(as there is only one status-structure). That means that either the
overridden processEvent(gishur.core.SweepEvent)
-method or the processEvent(gishur.core.SweepEvent)
-method of one SweepListener
will be called.
Before a sweep algorithm can be started with execute()
, an
event-structure must have been created with createEventStructure(gishur.core.Comparitor, boolean)
and
a status-structure including a matching Comparitor
as well with
createSSS(gishur.core.Comparitor, boolean)
. Besides, events must be added using insertEvent(int, java.lang.Object, java.lang.Object)
which can start the sweep.
The status-structure is a balanced BinarySearchTree
and can thus be
manipulated with tree methods.
SweepEvent
Constructor Summary | |
Sweep()
Empty constructor. |
|
Sweep(SweepListener sweep)
Creates a Sweep -object and defines sweep as its
SweepListener . |
Method Summary | |
void |
createEventStructure(Comparitor comparitor)
Creates a new event-structure with Comparitor
comparitor . |
void |
createEventStructure(Comparitor comparitor,
boolean smallfirst)
Creates a new event-structure with Comparitor
comparitor . |
void |
createSSS(Comparitor comparitor)
Creates a new status-structure which will be ordered by comparitor |
void |
createSSS(Comparitor comparitor,
boolean smallfirst)
Creates a new status-structure which will be ordered by comparitor in the order defined by smallfirst . |
void |
execute()
Starts the execution of the Sweep . |
void |
insertEvent(int id,
java.lang.Object key,
java.lang.Object value)
Inserts an event into the event-structure. |
void |
processEvent(SweepEvent e)
Processes SweepEvent e . |
void |
setSweepListener(SweepListener sweep)
Sets the SweepListener of this Sweep to sweep .
|
BinarySearchTree |
sss()
Returns the status-structure. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Sweep()
public Sweep(SweepListener sweep)
Sweep
-object and defines sweep
as its
SweepListener
.sweep
- new SweepListener
Method Detail |
public void setSweepListener(SweepListener sweep)
SweepListener
of this Sweep
to sweep
.
That means that sweep
's processEvent(gishur.core.SweepEvent)
-method will be
called when execution starts instead of this
'
processEvent(gishur.core.SweepEvent)
-routine.sweep
- new SweepListener
public final void execute()
Sweep
. An event-structure must have been
defined before!
All events in the event-structure will be processed after each other calling
processEvent(gishur.core.SweepEvent)
. While this process is in work, new events can be
added to the structure. execute()
ends when the last event storedpublic void processEvent(SweepEvent e)
SweepEvent
e
.processEvent
in interface SweepListener
e
- a SweepEvent
public void createEventStructure(Comparitor comparitor, boolean smallfirst)
Comparitor
comparitor
. Besides, the chronological order of procession is
defined by smallfirst
.comparitor
- a Comparitor
providing order to the
event-structuresmallfirst
- if true
, 'smaller' events (due to
comparitor
!) will be processed before bigger ones,
otherwise after thempublic void createEventStructure(Comparitor comparitor)
Comparitor
comparitor
.comparitor
- a Comparitor
providing order to the
event-structurepublic void insertEvent(int id, java.lang.Object key, java.lang.Object value)
id
- the event-idkey
- the key which defines the position of this event inside the
event-structure (by being compared to the other events' keys by the
structure's Comparitor
)value
- the value which shall be stored for the eventpublic void createSSS(Comparitor comparitor, boolean smallfirst)
comparitor
in the order defined by smallfirst
.comparitor
- a Comparitor
defining an order on the new
structuresmallfirst
- if true
smaller objects will be stored first,
otherwise vice versapublic void createSSS(Comparitor comparitor)
comparitor
comparitor
- a Comparitor
defining an order on the new
structurepublic BinarySearchTree sss()
Sweep's
status-structure as a
RedBlackTree
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |