Fix in PeList: problem in the generics declaration.

parent dc88765a
...@@ -31,7 +31,7 @@ public class PeList { ...@@ -31,7 +31,7 @@ public class PeList {
* @pre id >= 0 * @pre id >= 0
* @post $none * @post $none
*/ */
public static <T extends Pe> Pe getById(List<Pe> peList, int id) { public static <T extends Pe> Pe getById(List<T> peList, int id) {
for (Pe pe : peList) { for (Pe pe : peList) {
if (pe.getId() == id) { if (pe.getId() == id) {
return pe; return pe;
...@@ -49,7 +49,7 @@ public class PeList { ...@@ -49,7 +49,7 @@ public class PeList {
* @pre id >= 0 * @pre id >= 0
* @post $none * @post $none
*/ */
public static <T extends Pe> int getMips(List<Pe> peList, int id) { public static <T extends Pe> int getMips(List<T> peList, int id) {
Pe pe = getById(peList, id); Pe pe = getById(peList, id);
if (pe != null) { if (pe != null) {
return pe.getMips(); return pe.getMips();
...@@ -65,7 +65,7 @@ public class PeList { ...@@ -65,7 +65,7 @@ public class PeList {
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public static <T extends Pe> int getTotalMips(List<Pe> peList) { public static <T extends Pe> int getTotalMips(List<T> peList) {
int totalMips = 0; int totalMips = 0;
for (Pe pe : peList) { for (Pe pe : peList) {
totalMips += pe.getMips(); totalMips += pe.getMips();
...@@ -79,7 +79,7 @@ public class PeList { ...@@ -79,7 +79,7 @@ public class PeList {
* @param peList the pe list * @param peList the pe list
* @return the utilization * @return the utilization
*/ */
public static <T extends Pe> double getMaxUtilization(List<Pe> peList) { public static <T extends Pe> double getMaxUtilization(List<T> peList) {
double maxUtilization = 0; double maxUtilization = 0;
for (Pe pe : peList) { for (Pe pe : peList) {
double utilization = pe.getPeProvisioner().getUtilization(); double utilization = pe.getPeProvisioner().getUtilization();
...@@ -97,7 +97,7 @@ public class PeList { ...@@ -97,7 +97,7 @@ public class PeList {
* @param peList the pe list * @param peList the pe list
* @return the utilization * @return the utilization
*/ */
public static <T extends Pe> double getMaxUtilizationAmongVmsPes(List<Pe> peList, Vm vm) { public static <T extends Pe> double getMaxUtilizationAmongVmsPes(List<T> peList, Vm vm) {
double maxUtilization = 0; double maxUtilization = 0;
for (Pe pe : peList) { for (Pe pe : peList) {
if (pe.getPeProvisioner().getAllocatedMipsForVm(vm) == null) { if (pe.getPeProvisioner().getAllocatedMipsForVm(vm) == null) {
...@@ -119,7 +119,7 @@ public class PeList { ...@@ -119,7 +119,7 @@ public class PeList {
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public static <T extends Pe> Pe getFreePe(List<Pe> peList) { public static <T extends Pe> Pe getFreePe(List<T> peList) {
for (Pe pe : peList) { for (Pe pe : peList) {
if (pe.getStatus() == Pe.FREE) { if (pe.getStatus() == Pe.FREE) {
return pe; return pe;
...@@ -136,7 +136,7 @@ public class PeList { ...@@ -136,7 +136,7 @@ public class PeList {
* @pre $none * @pre $none
* @post $result >= 0 * @post $result >= 0
*/ */
public static <T extends Pe> int getNumberOfFreePes(List<Pe> peList) { public static <T extends Pe> int getNumberOfFreePes(List<T> peList) {
int cnt = 0; int cnt = 0;
for (Pe pe : peList) { for (Pe pe : peList) {
if (pe.getStatus() == Pe.FREE) { if (pe.getStatus() == Pe.FREE) {
...@@ -157,7 +157,7 @@ public class PeList { ...@@ -157,7 +157,7 @@ public class PeList {
* @pre peID >= 0 * @pre peID >= 0
* @post $none * @post $none
*/ */
public static <T extends Pe> boolean setPeStatus(List<Pe> peList, int id, int status) { public static <T extends Pe> boolean setPeStatus(List<T> peList, int id, int status) {
Pe pe = getById(peList, id); Pe pe = getById(peList, id);
if (pe != null) { if (pe != null) {
pe.setStatus(status); pe.setStatus(status);
...@@ -174,7 +174,7 @@ public class PeList { ...@@ -174,7 +174,7 @@ public class PeList {
* @pre $none * @pre $none
* @post $result >= 0 * @post $result >= 0
*/ */
public static <T extends Pe> int getNumberOfBusyPes(List<Pe> peList) { public static <T extends Pe> int getNumberOfBusyPes(List<T> peList) {
int cnt = 0; int cnt = 0;
for (Pe pe : peList) { for (Pe pe : peList) {
if (pe.getStatus() == Pe.BUSY) { if (pe.getStatus() == Pe.BUSY) {
...@@ -194,7 +194,7 @@ public class PeList { ...@@ -194,7 +194,7 @@ public class PeList {
* @param failed the new value for the "failed" parameter * @param failed the new value for the "failed" parameter
*/ */
public static <T extends Pe> void setStatusFailed( public static <T extends Pe> void setStatusFailed(
List<Pe> peList, List<T> peList,
String resName, String resName,
int hostId, int hostId,
boolean failed) { boolean failed) {
...@@ -216,7 +216,7 @@ public class PeList { ...@@ -216,7 +216,7 @@ public class PeList {
* @param failed the new value for the "failed" parameter * @param failed the new value for the "failed" parameter
* @param peList the pe list * @param peList the pe list
*/ */
public static <T extends Pe> void setStatusFailed(List<Pe> peList, boolean failed) { public static <T extends Pe> void setStatusFailed(List<T> peList, boolean failed) {
// a loop to set the status of all the PEs in this machine // a loop to set the status of all the PEs in this machine
for (Pe pe : peList) { for (Pe pe : peList) {
if (failed) { if (failed) {
...@@ -227,4 +227,4 @@ public class PeList { ...@@ -227,4 +227,4 @@ public class PeList {
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment