Exemplo n.º 1
0
 /** {@inheritDoc} */
 public boolean forEachEntry(TShortShortProcedure procedure) {
   byte[] states = _states;
   short[] keys = _set;
   short[] values = _values;
   for (int i = keys.length; i-- > 0; ) {
     if (states[i] == FULL && !procedure.execute(keys[i], values[i])) {
       return false;
     }
   }
   return true;
 }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  public boolean retainEntries(TShortShortProcedure procedure) {
    boolean modified = false;
    byte[] states = _states;
    short[] keys = _set;
    short[] values = _values;

    // Temporarily disable compaction. This is a fix for bug #1738760
    tempDisableAutoCompaction();
    try {
      for (int i = keys.length; i-- > 0; ) {
        if (states[i] == FULL && !procedure.execute(keys[i], values[i])) {
          removeAt(i);
          modified = true;
        }
      }
    } finally {
      reenableAutoCompaction(true);
    }

    return modified;
  }