Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 21st, 2010 | Syntax: Java | Size: 1.24 KB | Hits: 53 | Expires: Never
Copy text to clipboard
  1.         public Vector<Object> getGlobalMaximum() {
  2.  
  3.                 DatasetMaxValComparator s = new DatasetMaxValComparator();
  4.                 Vector<Object> globalMax = new Vector<Object>();
  5.                 ArrayList<String> names = new ArrayList<String>();
  6.  
  7.                 Set<String> keys = db.getAllData().keySet();
  8.                 Iterator<String> it_globMax = keys.iterator();
  9.                 List<Dataset> sets;
  10.                 String key = "";
  11.                 String name = "";
  12.                 Dataset values = null;
  13.                 double max = Integer.MIN_VALUE;
  14.  
  15.                 while (it_globMax.hasNext()) {
  16.  
  17.                         String share = (String) it_globMax.next().toString();
  18.                         names.add(share);
  19.  
  20.                 }
  21.                 for (int i = 0; i < names.size(); i++) {
  22.                         key = names.get(i);
  23.                         if (getLocalMaximum(names.get(i)).getHigh() > max) {
  24.                                 max = getLocalMaximum(names.get(i)).getHigh();
  25.                                 name = names.get(i);
  26.                                 sets = db.getEntry(key);
  27.                                 Collections.sort(sets, s);
  28.                                 values = sets.get(0);
  29.  
  30.                         } else if (getLocalMaximum(names.get(i)).getHigh() == max) {
  31.                                 int alph = key.compareTo(names.get(i));
  32.                                 if (alph > 0) {
  33.                                         max = getLocalMaximum(names.get(i)).getHigh();
  34.                                         name = names.get(i);
  35.                                         sets = db.getEntry(key);
  36.                                         Collections.sort(sets, s);
  37.                                         values = sets.get(0);
  38.                                 }
  39.  
  40.                         }
  41.                 }
  42.                 globalMax.add(0, name);
  43.                 globalMax.add(1, values);
  44.  
  45.                 return globalMax;
  46.  
  47.         }