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 public class ConflictList
9 public int noConflicts; // the number of conflicts
10 private Vector conflicts; // the conflicts
12 public ConflictList() {
14 conflicts=new Vector(100);
22 public Conflict conflictAt(int index) {
23 return (Conflict) conflicts.elementAt(index);
26 public String printInfo() {
31 st=""+noConflicts+" conflicts\n";
32 for( int i = 0; i < conflicts.size(); ++i ) {
33 Conflict cAux=(Conflict) conflicts.elementAt(i);
40 public void newConflict(Point4d coord, Flight f1, Flight f2) {
42 conflicts.addElement(new Conflict(coord,f1,f2));
45 public Conflict findConflict(Flight f1, Flight f2) {
46 for( int i = 0; i < conflicts.size(); ++i ) {
47 Conflict cAux=(Conflict) conflicts.elementAt(i);
48 if (cAux.hasFlights(f1,f2))
54 public int findConflictIndex(Flight f1, Flight f2) {
55 for( int i = 0; i < conflicts.size(); ++i ) {
56 Conflict cAux=(Conflict) conflicts.elementAt(i);
57 if (cAux.hasFlights(f1,f2))
63 public void removeConflict(Flight f1, Flight f2) {
65 int cAuxIndex=findConflictIndex(f1,f2);
66 conflicts.removeElementAt(cAuxIndex);