/** * Increments the primitive value mapped to key by 1 * * @param key the key of the value to increment * @return true if a mapping was found and modified. */ public boolean increment(float key) { return adjustValue(key, 1); }
/** * Empties the map. */ @Override // GemStoneAddition public void clear() { this._map.clear(); }
/** * checks for the present of <tt>key</tt> in the keys of the map. * * @param key an <code>float</code> value * @return a <code>boolean</code> value */ public boolean containsKey(float key) { return contains(key); }
if (_map.equals(other)) { return true; // comparing two trove maps } else if (other instanceof Map) { Map that = (Map)other; if (that.size() != _map.size()) { return false; // different sizes, no need to compare } else { // now we have to do it the hard way float k = unwrapKey(key); long v = unwrapValue(val); if (_map.containsKey(k) && v == _map.get(k)) {
/** * Compares this map with another map for equality of their stored * entries. * * @param other an <code>Object</code> value * @return a <code>boolean</code> value */ @Override // GemStoneAddition public boolean equals(Object other) { if (! (other instanceof TFloatLongHashMap)) { return false; } TFloatLongHashMap that = (TFloatLongHashMap)other; if (that.size() != this.size()) { return false; } return forEachEntry(new EqProcedure(that)); }
/** * Retrieves the value for <tt>key</tt> * * @param key an <code>Object</code> value * @return the value of <tt>key</tt> or null if no such mapping exists. */ @Override // GemStoneAddition public Object get(Object key) { float k = unwrapKey(key); long v = _map.get(k); // 0 may be a false positive since primitive maps // cannot return null, so we have to do an extra // check here. if (v == 0) { return _map.containsKey(k) ? wrapValue(v) : null; } else { return wrapValue(v); } }
private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); // number of entries stream.writeInt(_size); SerializationProcedure writeProcedure = new SerializationProcedure(stream); if (! forEachEntry(writeProcedure)) { throw writeProcedure.exception; } }
/** * Executes <tt>procedure</tt> for each key in the map. * * @param procedure a <code>TFloatProcedure</code> value * @return false if the loop over the keys terminated because * the procedure returned false for some key. */ public boolean forEachKey(TFloatProcedure procedure) { return forEach(procedure); }
/** * Checks for the present of <tt>key</tt> in the keys of the map. * * @param key an <code>Object</code> value * @return a <code>boolean</code> value */ @Override // GemStoneAddition public boolean containsKey(Object key) { return _map.containsKey(unwrapKey(key)); }
/** * Checks for the presence of <tt>val</tt> in the values of the map. * * @param val an <code>Object</code> value * @return a <code>boolean</code> value */ @Override // GemStoneAddition public boolean containsValue(Object val) { return _map.containsValue(unwrapValue(val)); }
/** * Clones the underlying trove collection and returns the clone wrapped in a new * decorator instance. This is a shallow clone except where primitives are * concerned. * * @return a copy of the receiver */ @Override // GemStoneAddition public Object clone() { try { TFloatLongHashMapDecorator copy = (TFloatLongHashMapDecorator) super.clone(); copy._map = (TFloatLongHashMap)_map.clone(); return copy; } catch (CloneNotSupportedException e) { // assert(false); throw new InternalError(); // we are cloneable, so this does not happen } }
@Override // GemStoneAddition public int hashCode() { HashProcedure p = new HashProcedure(); forEachEntry(p); return p.getHashCode(); }