added smaller version of directo for something in between tiny and full tests of...
[IRC.git] / Robust / src / Benchmarks / mlp / directto / mlp-small-for-testing / ConflictList.java
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
4
5 //import java.util.*;
6
7 public class ConflictList 
8 {   
9   public int noConflicts; // the number of conflicts
10   private Vector conflicts; // the conflicts
11         
12   public ConflictList() {
13     noConflicts=0;
14     conflicts=new Vector(100);
15   }
16     
17   public void clear() {         
18     noConflicts=0;
19     conflicts.clear();
20   }
21
22   public Conflict conflictAt(int index) {
23     return (Conflict) conflicts.elementAt(index);
24   }
25     
26   public String printInfo() {
27     String st;
28     if (noConflicts==0)
29       st="No conflicts!";
30     else {
31       st=""+noConflicts+" conflicts\n";
32       for( int i = 0; i < conflicts.size(); ++i ) {
33         Conflict cAux=(Conflict) conflicts.elementAt(i);
34         st=st+"\n"+cAux;
35       }
36     }
37     return st;
38   }
39   
40   public void newConflict(Point4d coord, Flight f1, Flight f2) {
41     noConflicts++;
42     conflicts.addElement(new Conflict(coord,f1,f2));
43   }
44   
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))
49         return cAux;
50     }
51     return null;
52   }
53
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))
58         return i;
59     }
60     return -1;
61   }
62   
63   public void removeConflict(Flight f1, Flight f2) {
64     noConflicts--;
65     int cAuxIndex=findConflictIndex(f1,f2);
66     conflicts.removeElementAt(cAuxIndex);
67   }
68 }