neosim.implementation
Class EventListImpl

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--neosim.implementation.EventListImpl

public class EventListImpl
extends java.util.Vector
implements EventList

This class implements an event queue used internally to manage the list of future and deferred Events. It works like a normal FIFO queue, but during insertion events are kept in order from the smallest time stamp to the largest. This means the next event to occur will be at the top of the queue.

The current implementation is uses a Vector to store the queue and is inefficient for popping and inserting elements because the rest of the array has to be moved down one space. A better method would be to use a circular array.

See Also:
Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
EventListImpl()
          Allocates a new EventListImpl object.
EventListImpl(int initialCapacity)
          Allocates a new EventList object, with an initial capacity.
 
Method Summary
 void add(Event new_event)
          Add a new event to the queue, preserving the temporal order of the events in the queue.
 java.util.Vector getEvents()
          Return the vector of events
 boolean hasMoreElements()
          Returns true if there are any more events in the list
 Event pop()
          Remove and return the event at the top of the queue.
 Event top()
          Return the event at the top of the queue, without removing it.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventListImpl

public EventListImpl()
Allocates a new EventListImpl object.

EventListImpl

public EventListImpl(int initialCapacity)
Allocates a new EventList object, with an initial capacity.
Parameters:
initialCapacity - The initial capacity of the queue.
Method Detail

pop

public Event pop()
Remove and return the event at the top of the queue.
Specified by:
pop in interface EventList
Returns:
The next event.

top

public Event top()
Return the event at the top of the queue, without removing it.
Specified by:
top in interface EventList
Returns:
The next event.

add

public void add(Event new_event)
Add a new event to the queue, preserving the temporal order of the events in the queue.
Specified by:
add in interface EventList
Parameters:
new_event - The event to be put on the queue.

hasMoreElements

public boolean hasMoreElements()
Returns true if there are any more events in the list
Specified by:
hasMoreElements in interface EventList
Returns:
true if any more events

getEvents

public java.util.Vector getEvents()
Return the vector of events
Specified by:
getEvents in interface EventList