home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 1002 b | 51 lines |
- // TsolTimes.java
- // 22.03.96
- //
- // a liste of metro times
-
- package cybcerone.main;
-
- import java.util.Vector;
- import java.util.Enumeration;
-
- import cybcerone.utils.Date;
-
- /**
- * A group of TsolTime objects, and a means of finding the next one.
- */
- class TsolTimes {
- private Vector times;
-
- /* to speed up the getNext method */
- private TsolTime next;
-
- public TsolTimes (Vector theTimes) {
- times = theTimes;
- }
-
- public TsolTime getNext (TsolTime theTime) {
- if (times != null && times.size () > 0) {
- next = (TsolTime)times.firstElement ();
- while (theTime.after (next) && times.size () > 0) {
- times.removeElementAt (0);
- if (times.size () > 0)
- next = (TsolTime)times.firstElement ();
- }
- if (theTime.after (next))
- return null;
- else
- return next;
- }
- return null;
- }
-
- public TsolTime getNext (Date theDate) {
- return getNext (new TsolTime (theDate));
- }
-
- /** How many times are left */
- public int size () {
- return times.size ();
- }
- }
-