]> git.somenet.org - pub/jan/lsdc.git/blob - src/at/ac/tuwien/lsdc/types/SortedPhysicalMachine.java
move outsourced event handling from SchedulerB to AbstractScheduler
[pub/jan/lsdc.git] / src / at / ac / tuwien / lsdc / types / SortedPhysicalMachine.java
1 package at.ac.tuwien.lsdc.types;
2
3 public class SortedPhysicalMachine implements Comparable<SortedPhysicalMachine> {
4
5         private PhysicalMachine pm;
6         final int BEFORE = -1;
7         final int EQUAL = 0;
8         final int AFTER = 1;
9         
10         public SortedPhysicalMachine(PhysicalMachine pm) {
11                 this.pm = pm;
12         }
13         
14         @Override
15         public int compareTo(SortedPhysicalMachine other) {
16                 if(this == other)
17                         return EQUAL;
18                 
19                 if(pm.getAverageUtilization() < other.getPm().getAverageUtilization())
20                         return BEFORE;
21                 else if(pm.getAverageUtilization() > other.getPm().getAverageUtilization())
22                         return AFTER;
23                 else
24                         return EQUAL;
25         }
26
27         
28         public PhysicalMachine getPm() {
29                 return pm;
30         }
31         
32 }