View Javadoc

1   /*
2    * Created on Mar 28, 2004
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.dsol.eventlists;
11  
12  import java.io.Serializable;
13  import java.util.Collection;
14  import java.util.Iterator;
15  
16  import nl.tudelft.simulation.dsol.formalisms.devs.SimEventInterface;
17  
18  /***
19   * The EventListInterface defines the required methods for discrete event lists.
20   * A number of competitive algoritms can be used to implement such eventlist.
21   * Among these implementations are the Red-Black, the SplayTree, and others.
22   * <p>
23   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
24   * University of Technology </a>, the Netherlands. <br>
25   * See for project information <a href="http://www.simulation.tudelft.nl">
26   * www.simulation.tudelft.nl </a> <br>
27   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
28   * License (GPL) </a>, no warranty <br>
29   * 
30   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
31   *         Jacobs </a>
32   * @version 1.7 2004-03-28
33   * @since 1.0
34   */
35  public interface EventListInterface extends Serializable
36  {
37  	/***
38  	 * adds an event to the eventlist
39  	 * 
40  	 * @param event the event to add
41  	 * @return true whenever the event was not already scheduled.
42  	 */
43  	boolean add(final SimEventInterface event);
44  
45  	/***
46  	 * adds a collection of events to the tree
47  	 * 
48  	 * @param collection the collection
49  	 * @return true whenever the collection was sucessfully added.
50  	 */
51  	boolean addAll(final Collection collection);
52  
53  	/***
54  	 * clears the eventlist by removing all its scheduled events.
55  	 */
56  	void clear();
57  
58  	/***
59  	 * returns whether event is an entry of the eventlist
60  	 * 
61  	 * @param event the event
62  	 * @return true if event in tree; otherwise false.
63  	 */
64  	boolean contains(final SimEventInterface event);
65  
66  	/***
67  	 * returns whether the collection is in the list.
68  	 * 
69  	 * @param collection the collection to test
70  	 * @return true if event in tree; otherwise false.
71  	 */
72  	boolean containsAll(final Collection collection);
73  
74  	/***
75  	 * returns the first scheduled event
76  	 * 
77  	 * @return first scheduled event.
78  	 */
79  	SimEventInterface first();
80  
81  	/***
82  	 * returns whether the eventlist is empty
83  	 * 
84  	 * @return true if empty.
85  	 */
86  	boolean isEmpty();
87  
88  	/***
89  	 * returns the iterator for this eventlist
90  	 * 
91  	 * @return the iterator
92  	 */
93  	Iterator iterator();
94  
95  	/***
96  	 * returns the last scheduled event
97  	 * 
98  	 * @return last scheduled event.
99  	 */
100 	SimEventInterface last();
101 
102 	/***
103 	 * removes the event from this tree
104 	 * 
105 	 * @param event the event to be removed
106 	 * @return true if the event was in the tree and succesfully removed.
107 	 */
108 	boolean remove(final SimEventInterface event);
109 
110 	/***
111 	 * removes a collection of events from this tree
112 	 * 
113 	 * @param collection the colleciton
114 	 * @return true if the event was in the tree and succesfully removed.
115 	 */
116 	boolean removeAll(final Collection collection);
117 
118 	/***
119 	 * removes the first event from the eventlist.
120 	 * 
121 	 * @return the first event
122 	 */
123 	SimEventInterface removeFirst();
124 
125 	/***
126 	 * removes the last event from the eventlist.
127 	 * 
128 	 * @return the last event
129 	 */
130 	SimEventInterface removeLast();
131 
132 	/***
133 	 * returns the number of scheduled events
134 	 * 
135 	 * @return the number of scheduled events.
136 	 */
137 	int size();
138 
139 	/***
140 	 * returns the eventlist as array of simevents
141 	 * 
142 	 * @return the eventlist as array of simevents.
143 	 */
144 	SimEventInterface[] toArray();
145 }