public String toString() { final StringBuilder buf = new StringBuilder("{"); forEachEntry(new TObjectObjectProcedure<K, V>() { private boolean first = true; public boolean execute(K key, V value) { if (first) first = false; else buf.append(","); buf.append(key); buf.append("="); buf.append(value); return true; } }); buf.append("}"); return buf.toString(); }
@Override public <K, V> boolean forEachEntry(Map<K, V> map, final MapProcedure<K, V> procedure) { if (map instanceof THashMap) { return ((THashMap<K, V>) map).forEachEntry(new TObjectObjectProcedure<K, V>() { @Override public boolean execute(K key, V value) { return procedure.execute(key, value); } }); } return super.forEachEntry(map, procedure); }
public void writeExternal(ObjectOutput out) throws IOException { // VERSION out.writeByte(1); // NOTE: Super was not written in version 0 super.writeExternal(out); // NUMBER OF ENTRIES out.writeInt(_size); // ENTRIES SerializationProcedure writeProcedure = new SerializationProcedure(out); if (!forEachEntry(writeProcedure)) { throw writeProcedure.exception; } }
public int hashCode() { HashProcedure p = new HashProcedure(); forEachEntry(p); return p.getHashCode(); }
/** * 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 */ public boolean equals(Object other) { if (!(other instanceof Map)) { return false; } Map<K, V> that = (Map<K, V>) other; if (that.size() != this.size()) { return false; } return forEachEntry(new EqProcedure<K, V>(that)); }