/** * {@inheritDoc} * * <p>Note that an empty container may still contain many deleted keys (that occupy buffer * space). Adding even a single element to such a container may cause rehashing.</p> */ @Override public boolean isEmpty() { return size() == 0; }
/** * {@inheritDoc} */ @Override public int size() { return this.owner.size(); }
/** * {@inheritDoc} */ @Override public int size() { return this.owner.size(); }
@Override public char[] toArray(final char[] target) { int count = 0; if (this.owner.allocatedDefaultKey) { target[count++] = ('\u0000'); } final char[] keys = ((this.owner.keys)); for (int i = 0; i < keys.length; i++) { char existing; if (!((existing = keys[i]) == '\u0000')) { target[count++] = existing; } } assert count == this.owner.size(); return target; } };
@Override public double[] toArray(final double[] target) { int count = 0; if (this.owner.allocatedDefaultKey) { target[count++] = this.owner.allocatedDefaultKeyValue; } final char[] keys = ((this.owner.keys)); final double[] values = ((this.owner.values)); for (int i = 0; i < values.length; i++) { if ((!(((keys)[(i)]) == '\u0000'))) { target[count++] = values[i]; } } assert count == this.owner.size(); return target; } }
/** * {@inheritDoc} * Indeed removes all the (key,value) pairs matching * (key ? , e) with the same e, from the map. */ @Override public int removeAll(final double e) { final int before = this.owner.size(); if (this.owner.allocatedDefaultKey) { if ((Double.doubleToLongBits((e)) == Double.doubleToLongBits((this.owner.allocatedDefaultKeyValue)))) { this.owner.allocatedDefaultKey = false; } } final char[] keys = ((this.owner.keys)); final double[] values = ((this.owner.values)); for (int slot = 0; slot < keys.length;) { if ((!(((keys)[(slot)]) == '\u0000')) && (Double.doubleToLongBits((e)) == Double.doubleToLongBits((values[slot])))) { shiftConflictingKeys(slot); // Shift, do not increment slot. } else { slot++; } } return before - this.owner.size(); }
/** * {@inheritDoc} * Indeed removes all the (key,value) pairs matching * the predicate for the values, from the map. */ @Override public int removeAll(final DoublePredicate predicate) { final int before = this.owner.size(); if (this.owner.allocatedDefaultKey) { if (predicate.apply(this.owner.allocatedDefaultKeyValue)) { this.owner.allocatedDefaultKey = false; } } final char[] keys = ((this.owner.keys)); final double[] values = ((this.owner.values)); for (int slot = 0; slot < keys.length;) { if ((!(((keys)[(slot)]) == '\u0000')) && predicate.apply(values[slot])) { shiftConflictingKeys(slot); // Shift, do not increment slot. } else { slot++; } } return before - this.owner.size(); }
/** * {@inheritDoc} */ @Override public CharDoubleHashMap clone() { //clone to size() to prevent some cases of exponential sizes, final CharDoubleHashMap cloned = new CharDoubleHashMap(this.size(), this.loadFactor); //We must NOT clone because of independent perturbations seeds cloned.putAll(this); return cloned; }
/** * {@inheritDoc} */ @Override public int removeAll(final CharDoublePredicate predicate) { final int before = this.size(); if (this.allocatedDefaultKey) { if (predicate.apply(('\u0000'), this.allocatedDefaultKeyValue)) { this.allocatedDefaultKey = false; } } final char[] keys = ((this.keys)); final double[] values = ((this.values)); for (int i = 0; i < keys.length;) { char existing; if (!((existing = keys[i]) == '\u0000') && predicate.apply(existing, values[i])) { shiftConflictingKeys(i); // Shift, do not increment slot. } else { i++; } } return before - this.size(); }
/** * {@inheritDoc} */ @Override public int removeAll(final CharPredicate predicate) { final int before = this.size(); if (this.allocatedDefaultKey) { if (predicate.apply(('\u0000'))) { this.allocatedDefaultKey = false; } } final char[] keys = ((this.keys)); for (int i = 0; i < keys.length;) { char existing; if (!((existing = keys[i]) == '\u0000') && predicate.apply(existing)) { shiftConflictingKeys(i); // Shift, do not increment slot. } else { i++; } } return before - this.size(); }