public void lookup(B key) throws IOException {

    waitingNext = false;
    if (matchingMode == MATCHING_MODE.ALL_MATCHES) {
      lookupIndex = 0;
      for (int lookupIndexLocal = 0; lookupIndexLocal < lookupListSize; lookupIndexLocal++) {
        ILookupManagerUnit<B> tempLookup = lookupList[lookupIndexLocal];
        tempLookup.lookup(key);
      }
    } else {
      try {
        if (lookupKey.compareTo(key) == 0 && previousResultRetrieved) {
          nextIsPreviousResult = true;
        } else {
          previousResultRetrieved = false;
          previousResult = null;
        }
      } catch (NullPointerException e) {
        previousResultRetrieved = false;
        previousResult = null;
      }
      noMoreNext = false;
    }
    key.copyDataTo(lookupKey);
    lookupKeyIsInitialized = true;
  }
Exemplo n.º 2
0
 /**
  * Adds the value for the given key to the Table, or upgrades the value if an equal value already
  * exists (and if compareTo and equals differ)
  *
  * @param key: the key to add to the Table
  * @param value: the value to add to the Table
  */
 public void add(A key, B value) {
   Vector<B> list = multimap.get(key);
   if (!contains(key, value)) size++;
   if (list == null) {
     list = new Vector<B>(0, 1);
     list.add(value);
     multimap.put(key, list);
   } else {
     int index = list.indexOf(value);
     if (index == -1) list.add(value);
     else if (value.compareTo(list.get(index)) > 0) {
       list.remove(index);
       list.add(value);
     }
   }
 }