1 // This class keeps a list of conflicts.
2 // The conflicts are updated at every moment of time
3 // We detect only the first conflict between every pair of flights
7 final class ConflictList
9 public int noConflicts; // the number of conflicts
10 private ArrayList conflicts; // the conflicts
16 conflicts=new ArrayList(100);
25 public Conflict conflictAt(int index)
27 return (Conflict) conflicts.get(index);
30 public Iterator getConflicts()
32 return conflicts.iterator();
35 public String printInfo()
36 // this is a test procedure
43 st=""+noConflicts+" conflicts\n";
44 Iterator iter=getConflicts();
45 while (iter.hasNext())
47 Conflict cAux=(Conflict) iter.next();
54 public void newConflict(Point4d coord, Flight f1, Flight f2)
57 conflicts.add(new Conflict(coord,f1,f2));
61 public Conflict findConflict(Flight f1, Flight f2)
63 Iterator iter=getConflicts();
64 while (iter.hasNext())
66 Conflict cAux=(Conflict) iter.next();
67 if (cAux.hasFlights(f1,f2))
74 public void removeConflict(Flight f1, Flight f2)
77 Conflict cAux=findConflict(f1,f2);
78 conflicts.remove(cAux);