@SuppressWarnings("unchecked") public boolean containsKey(final double k) { // The starting point. int pos = (it.unimi.dsi.fastutil.HashCommon.murmurHash3(strategy.hashCode(k))) & mask; // There's always an unused entry. while (used[pos]) { if ((strategy.equals((key[pos]), (k)))) return true; pos = (pos + 1) & mask; } return false; }
public Double get(final Double ok) { final double k = ((ok).doubleValue()); // The starting point. int pos = (it.unimi.dsi.fastutil.HashCommon.murmurHash3(strategy.hashCode(k))) & mask; // There's always an unused entry. while (used[pos]) { if ((strategy.equals((key[pos]), (k)))) return (Double.valueOf(value[pos])); pos = (pos + 1) & mask; } return (null); }
@SuppressWarnings("unchecked") public double remove(final double k) { // The starting point. int pos = (it.unimi.dsi.fastutil.HashCommon.murmurHash3(strategy.hashCode(k))) & mask; // There's always an unused entry. while (used[pos]) { if ((strategy.equals((key[pos]), (k)))) { size--; final double v = value[pos]; shiftKeys(pos); return v; } pos = (pos + 1) & mask; } return defRetValue; }
@SuppressWarnings("unchecked") public Double remove(final Object ok) { final double k = ((((Double) (ok)).doubleValue())); // The starting point. int pos = (it.unimi.dsi.fastutil.HashCommon.murmurHash3(strategy.hashCode(k))) & mask; // There's always an unused entry. while (used[pos]) { if ((strategy.equals((key[pos]), (k)))) { size--; final double v = value[pos]; shiftKeys(pos); return (Double.valueOf(v)); } pos = (pos + 1) & mask; } return (null); }
/** * Adds an increment to value currently associated with a key. * * <p>Note that this method respects the {@linkplain #defaultReturnValue() default return value} * semantics: when called with a key that does not currently appears in the map, the key will be * associated with the default return value plus the given increment. * * @param k the key. * @param incr the increment. * @return the old value, or the {@linkplain #defaultReturnValue() default return value} if no * value was present for the given key. */ public double addTo(final double k, final double incr) { // The starting point. int pos = (it.unimi.dsi.fastutil.HashCommon.murmurHash3(strategy.hashCode(k))) & mask; // There's always an unused entry. while (used[pos]) { if ((strategy.equals((key[pos]), (k)))) { final double oldValue = value[pos]; value[pos] += incr; return oldValue; } pos = (pos + 1) & mask; } used[pos] = true; key[pos] = k; value[pos] = defRetValue + incr; if (++size >= maxFill) rehash(arraySize(size + 1, f)); if (ASSERTS) checkTable(); return defRetValue; }
public Double put(final Double ok, final Double ov) { final double v = ((ov).doubleValue()); final double k = ((ok).doubleValue()); // The starting point. int pos = (it.unimi.dsi.fastutil.HashCommon.murmurHash3(strategy.hashCode(k))) & mask; // There's always an unused entry. while (used[pos]) { if ((strategy.equals((key[pos]), (k)))) { final Double oldValue = (Double.valueOf(value[pos])); value[pos] = v; return oldValue; } pos = (pos + 1) & mask; } used[pos] = true; key[pos] = k; value[pos] = v; if (++size >= maxFill) rehash(arraySize(size + 1, f)); if (ASSERTS) checkTable(); return (null); }