|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjasi.sim.basic.event.Calendar
public final class Calendar
The event calendar. The calendar provides guaranteed log(n) time cost for the basic operations (push, pop, contains and remove). Algorithms are adaptations of those in Cormen, Leiserson, and Rivest's Introduction to Algorithms.
Constructor Summary | |
---|---|
Calendar()
Constructor of calendar, where the current start time of this calendar will be zero. |
|
Calendar(Time time)
Constructor of a calendar. |
Method Summary | |
---|---|
void |
addCalendarListener(CalendarListener listener)
Add an listener for state changes of this calendar. |
void |
clear()
Remove all events from this calendar. |
boolean |
contains(Event event)
Check, if this calendar contains a certain event. |
void |
deleteEventsEarlierThan(Time time)
Delete all events with an time earlier than a given time. |
Event |
find(Id id)
Find an event by its id in the calendar. |
Time |
getCurrentTime()
Get the current time of this calendar, that is given by the event time of the last event, which had been removed (popped) from this calendar. |
java.util.Collection<Event> |
getEventSet()
Retrieve an unmodifiable collection of all events in this calendar. |
void |
importEvent(Event event)
Add or push an event unchecked to this calendar. |
boolean |
isEmpty()
Check, if this calendar has no events. |
Event |
pop()
Pop the next event waiting from this calendar. |
void |
push(Event event)
Add or push an event to this calendar. |
Time |
readNextEventTime()
Get the event time of next event in this calendar. |
boolean |
remove(Event event)
Remove an event from this calendar. |
void |
removeCalendarListener(CalendarListener listener)
Remove an listener for state changes of this calendar. |
void |
setCurrentTime(Time time)
Set, i.e. increase, the time of this calendar. |
int |
size()
Get number of events in this calendar. |
java.lang.String |
toString()
Returns a string representation of this object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Calendar(Time time)
time
- The current start time of this calendar.public Calendar()
Method Detail |
---|
public void importEvent(Event event)
event
- The event to be pushed.
EventAlreadyPushedException
- The event has already been pushed to an calendar.public void push(Event event) throws EventToEarlyException, EventAlreadyPushedException
event
- The event to be pushed.
EventToEarlyException
- The event's time is smaller (earlier) than the current
time.
EventAlreadyPushedException
- The event has already been pushed to an calendar.public Event pop() throws EmptyCalendarException, EventAlreadyPoppedException, EventNotPushedException
EmptyCalendarException
- No events in calendar.
EventAlreadyPoppedException
- This event has already been popped from a calendar.
EventNotPushedException
- This event has not been pushed to a calendar.public Event find(Id id)
id
- The event's id.
public boolean remove(Event event)
event
- The event.
public void clear()
public boolean contains(Event event)
event
- That event
public boolean isEmpty()
public int size()
public Time readNextEventTime()
public void deleteEventsEarlierThan(Time time)
time
- The given reference time.public java.lang.String toString()
toString
in class java.lang.Object
public Time getCurrentTime()
public void setCurrentTime(Time time)
time
- The requested time.public java.util.Collection<Event> getEventSet()
public void addCalendarListener(CalendarListener listener)
listener
- The listener.public void removeCalendarListener(CalendarListener listener)
listener
- The listener.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |