Untitled
By: a guest | Mar 21st, 2010 | Syntax:
Java | Size: 1.24 KB | Hits: 53 | Expires: Never
public Vector<Object> getGlobalMaximum() {
DatasetMaxValComparator s = new DatasetMaxValComparator();
Vector<Object> globalMax = new Vector<Object>();
ArrayList<String> names = new ArrayList<String>();
Set<String> keys = db.getAllData().keySet();
Iterator<String> it_globMax = keys.iterator();
List<Dataset> sets;
String key = "";
String name = "";
Dataset values = null;
double max = Integer.MIN_VALUE;
while (it_globMax.hasNext()) {
String share = (String) it_globMax.next().toString();
names.add(share);
}
for (int i = 0; i < names.size(); i++) {
key = names.get(i);
if (getLocalMaximum(names.get(i)).getHigh() > max) {
max = getLocalMaximum(names.get(i)).getHigh();
name = names.get(i);
sets = db.getEntry(key);
Collections.sort(sets, s);
values = sets.get(0);
} else if (getLocalMaximum(names.get(i)).getHigh() == max) {
int alph = key.compareTo(names.get(i));
if (alph > 0) {
max = getLocalMaximum(names.get(i)).getHigh();
name = names.get(i);
sets = db.getEntry(key);
Collections.sort(sets, s);
values = sets.get(0);
}
}
}
globalMax.add(0, name);
globalMax.add(1, values);
return globalMax;
}