@Override protected Iterator mapEntryIterator() { return this.map.entrySet().iterator(); }
/** * Returns the hash code value for this map. The hash code of a map is defined to be the sum of * the hash codes of each entry in the map's <tt>entrySet()</tt> view. This ensures that * <tt>m1.equals(m2)</tt> implies that <tt>m1.hashCode()==m2.hashCode()</tt> for any two maps * <tt>m1</tt> and <tt>m2</tt>, as required by the general contract of {@link Object#hashCode}. * * <p> * This implementation iterates over <tt>entrySet()</tt>, calling * {@link java.util.Map.Entry#hashCode() hashCode()} on each element (entry) in the set, and * adding up the results. * * @return the hash code value for this map * @see java.util.Map.Entry#hashCode() * @see Object#equals(Object) * @see Set#equals(Object) */ public int hashCode() { int h = 0; Iterator<Entry> i = entrySet().iterator(); while (i.hasNext()) h += i.next().hashCode(); return h; }
private void putAllForCreate(ObjectIntHashMap m) { for (Iterator i = m.entrySet().iterator(); i.hasNext();) { Entry e = (Entry) i.next(); putForCreate(e.getKey(), e.getValue()); } }
/** * Returns a string representation of this map. The string representation consists of a list of * key-value mappings in the order returned by the map's <tt>entrySet</tt> view's iterator, * enclosed in braces (<tt>"{}"</tt>). Adjacent mappings are separated by the characters * <tt>", "</tt> (comma and space). Each key-value mapping is rendered as the key followed by an * equals sign (<tt>"="</tt>) followed by the associated value. Keys and values are converted to * strings as by {@link String#valueOf(Object)}. * * @return a string representation of this map */ public String toString() { Iterator<Entry> i = entrySet().iterator(); if (!i.hasNext()) return "{}"; StringBuilder sb = new StringBuilder(); sb.append('{'); for (;;) { Entry e = i.next(); Object key = e.getKey(); int value = e.getValue(); sb.append(key == this ? "(this Map)" : key); sb.append('='); sb.append(value); if (!i.hasNext()) return sb.append('}').toString(); sb.append(", "); } }
@Override public void toData(DataOutput out) throws IOException { DataSerializer.writeObject(this.elementType, out); out.writeInt(this.size()); this.writeNumNulls(out); // TODO:Asif: Should we actually pass the limit in serialization? // For the time being not passing , assuming PR Has parsed // it // out.writeInt(this.limit); int numLeft = this.size() - this.numNulls; for (Iterator<Entry> itr = this.map.entrySet().iterator(); itr.hasNext() && numLeft > 0;) { Entry entry = itr.next(); Object key = entry.getKey(); DataSerializer.writeObject(key, out); int occurrence = entry.getValue(); if (numLeft < occurrence) { occurrence = numLeft; } out.writeInt(occurrence); numLeft -= occurrence; } }
for (Iterator i = m.entrySet().iterator(); i.hasNext();) { Entry e = (Entry) i.next(); put(e.getKey(), e.getValue());
Iterator<Entry> i = entrySet().iterator(); while (i.hasNext()) { Entry e = i.next();