コード例 #1
0
 /** {@inheritDoc} */
 @Override
 public void transformValues(TCharFunction function) {
   TByteOffheapArray states = _states;
   TCharOffheapArray values = _values;
   for (int i = capacity(); i-- > 0; ) {
     if (states.get(i) == FULL) {
       values.put(i, function.execute(values.get(i)));
     }
   }
 }
コード例 #2
0
 /** {@inheritDoc} */
 @Override
 public boolean adjustValue(char key, char amount) {
   int index = index(key);
   if (index < 0) {
     return false;
   } else {
     char val = _values.get(index);
     _values.put(index, (char) (val + amount));
     return true;
   }
 }
コード例 #3
0
  private char doPut(char key, char value, int index) {
    char previous = no_entry_value;
    boolean isNewMapping = true;
    if (index < 0) {
      index = -index - 1;
      previous = _values.get(index);
      isNewMapping = false;
    }
    _values.put(index, value);

    if (isNewMapping) {
      postInsertHook(consumeFreeSlot);
    }

    return previous;
  }
コード例 #4
0
  /** {@inheritDoc} */
  @Override
  public char adjustOrPutValue(char key, char adjust_amount, char put_amount) {
    int index = insertKey(key);
    final boolean isNewMapping;
    final char newValue;
    if (index < 0) {
      index = -index - 1;
      newValue = (char) (_values.get(index) + adjust_amount);
      isNewMapping = false;
    } else {
      newValue = put_amount;
      isNewMapping = true;
    }

    _values.put(index, newValue);

    if (isNewMapping) {
      postInsertHook(consumeFreeSlot);
    }

    return newValue;
  }
コード例 #5
0
  /** {@inheritDoc} */
  @Override
  protected void rehash(int newCapacity) {
    int oldCapacity = capacity();

    TCharOffheapArray oldKeys = _set;
    TCharOffheapArray oldVals = _values;
    TByteOffheapArray oldStates = _states;

    _set = new TCharOffheapArray(newCapacity);
    _values = new TCharOffheapArray(newCapacity);
    _states = new TByteOffheapArray(newCapacity);

    for (int i = oldCapacity; i-- > 0; ) {
      if (oldStates.get(i) == FULL) {
        char o = oldKeys.get(i);
        int index = insertKey(o);
        _values.put(index, oldVals.get(i));
      }
    }
    oldKeys.free();
    oldVals.free();
    oldStates.free();
  }
コード例 #6
0
 /** {@inheritDoc} */
 @Override
 protected void removeAt(int index) {
   _values.put(index, no_entry_value);
   super.removeAt(index); // clear key, state; adjust size
 }