public Object getValue() { return iterator.getValue(); }
public Object getValue() { return iterator.getValue(); }
public Object getValue() { return iterator.getValue(); }
public Object getValue() { return iterator.getValue(); }
/** * Write the map out using a custom routine. */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeInt(size()); for (MapIterator it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); // key out.writeObject(it.getValue()); // value } }
/** * Write the map out using a custom routine. */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeInt(size()); for (MapIterator it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); // key out.writeObject(it.getValue()); // value } }
/** * Gets the hash code value for this map as per the API. * * @param type the KEY or VALUE int * @return the hash code value for this map */ private int doHashCode(final int type) { int total = 0; if (nodeCount > 0) { for (MapIterator it = new ViewMapIterator(this, type); it.hasNext(); ) { Object key = it.next(); Object value = it.getValue(); total += (key.hashCode() ^ value.hashCode()); } } return total; }
/** * Gets the string form of this map as per AbstractMap. * * @param type the KEY or VALUE int * @return the string form of this map */ private String doToString(final int type) { if (nodeCount == 0) { return "{}"; } StringBuffer buf = new StringBuffer(nodeCount * 32); buf.append('{'); MapIterator it = new ViewMapIterator(this, type); boolean hasNext = it.hasNext(); while (hasNext) { Object key = it.next(); Object value = it.getValue(); buf.append(key == this ? "(this Map)" : key) .append('=') .append(value == this ? "(this Map)" : value); hasNext = it.hasNext(); if (hasNext) { buf.append(", "); } } buf.append('}'); return buf.toString(); }
/** * Gets the hash code value for this map as per the API. * * @param type the KEY or VALUE int * @return the hash code value for this map */ private int doHashCode(final int type) { int total = 0; if (nodeCount > 0) { for (MapIterator it = new ViewMapIterator(this, type); it.hasNext(); ) { Object key = it.next(); Object value = it.getValue(); total += (key.hashCode() ^ value.hashCode()); } } return total; }
for (MapIterator it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); out.writeObject(it.getValue());
while (hasNext) { Object key = it.next(); Object value = it.getValue(); buf.append(key == this ? "(this Map)" : key) .append('=')
/** * Writes the map data to the stream. This method must be overridden if a * subclass must be setup before <code>put()</code> is used. * <p> * Serialization is not one of the JDK's nicest topics. Normal serialization will * initialise the superclass before the subclass. Sometimes however, this isn't * what you want, as in this case the <code>put()</code> method on read can be * affected by subclass state. * <p> * The solution adopted here is to serialize the state data of this class in * this protected method. This method must be called by the * <code>writeObject()</code> of the first serializable subclass. * <p> * Subclasses may override if they have a specific field that must be present * on read before this implementation will work. Generally, the read determines * what must be serialized here, if anything. * * @param out the output stream */ protected void doWriteObject(ObjectOutputStream out) throws IOException { out.writeFloat(loadFactor); out.writeInt(data.length); out.writeInt(size); for (MapIterator it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); out.writeObject(it.getValue()); } }
/** * Writes the map data to the stream. This method must be overridden if a * subclass must be setup before <code>put()</code> is used. * <p> * Serialization is not one of the JDK's nicest topics. Normal serialization will * initialise the superclass before the subclass. Sometimes however, this isn't * what you want, as in this case the <code>put()</code> method on read can be * affected by subclass state. * <p> * The solution adopted here is to serialize the state data of this class in * this protected method. This method must be called by the * <code>writeObject()</code> of the first serializable subclass. * <p> * Subclasses may override if they have a specific field that must be present * on read before this implementation will work. Generally, the read determines * what must be serialized here, if anything. * * @param out the output stream */ protected void doWriteObject(ObjectOutputStream out) throws IOException { out.writeFloat(loadFactor); out.writeInt(data.length); out.writeInt(size); for (MapIterator it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); out.writeObject(it.getValue()); } }
for (MapIterator it = new ViewMapIterator(this, type); it.hasNext(); ) { Object key = it.next(); Object value = it.getValue(); if (value.equals(other.get(key)) == false) { return false;
/** * Test that the full list iterator contract is correct. */ public void testFullMapIterator() { if (supportsFullIterator() == false) { return; } MapIterator it = makeFullMapIterator(); Map map = getMap(); assertEquals(true, it.hasNext()); assertEquals(true, it.hasNext()); Set set = new HashSet(); while (it.hasNext()) { // getKey Object key = it.next(); assertSame("it.next() should equals getKey()", key, it.getKey()); assertTrue("Key must be in map", map.containsKey(key)); assertTrue("Key must be unique", set.add(key)); // getValue Object value = it.getValue(); if (isGetStructuralModify() == false) { assertSame("Value must be mapped to key", map.get(key), value); } assertTrue("Value must be in map", map.containsValue(value)); verify(); } }
public void testMapIteratorRemoveGetValue() { if (supportsRemove() == false) { return; } MapIterator it = makeFullMapIterator(); Map map = getMap(); Map confirmed = getConfirmedMap(); assertEquals(true, it.hasNext()); Object key = it.next(); it.remove(); confirmed.remove(key); verify(); try { it.getValue(); fail(); } catch (IllegalStateException ex) {} verify(); }
public void testGetValueByIndex() { resetEmpty(); ListOrderedMap lom = (ListOrderedMap) map; try { lom.getValue(0); } catch (IndexOutOfBoundsException ex) {} try { lom.getValue(-1); } catch (IndexOutOfBoundsException ex) {} resetFull(); lom = (ListOrderedMap) map; try { lom.getValue(-1); } catch (IndexOutOfBoundsException ex) {} try { lom.getValue(lom.size()); } catch (IndexOutOfBoundsException ex) {} int i = 0; for (MapIterator it = lom.mapIterator(); it.hasNext(); i++) { it.next(); assertSame(it.getValue(), lom.getValue(i)); } }
public void testGetValueByIndex() { resetEmpty(); ListOrderedMap lom = (ListOrderedMap) map; try { lom.getValue(0); } catch (IndexOutOfBoundsException ex) {} try { lom.getValue(-1); } catch (IndexOutOfBoundsException ex) {} resetFull(); lom = (ListOrderedMap) map; try { lom.getValue(-1); } catch (IndexOutOfBoundsException ex) {} try { lom.getValue(lom.size()); } catch (IndexOutOfBoundsException ex) {} int i = 0; for (MapIterator it = lom.mapIterator(); it.hasNext(); i++) { it.next(); assertSame(it.getValue(), lom.getValue(i)); } }
public void testGetValueByIndex() { resetEmpty(); LinkedMap lm = (LinkedMap) map; try { lm.getValue(0); } catch (IndexOutOfBoundsException ex) {} try { lm.getValue(-1); } catch (IndexOutOfBoundsException ex) {} resetFull(); lm = (LinkedMap) map; try { lm.getValue(-1); } catch (IndexOutOfBoundsException ex) {} try { lm.getValue(lm.size()); } catch (IndexOutOfBoundsException ex) {} int i = 0; for (MapIterator it = lm.mapIterator(); it.hasNext(); i++) { it.next(); assertSame(it.getValue(), lm.getValue(i)); } }
} catch (IllegalStateException ex) {} try { IteratorUtils.EMPTY_MAP_ITERATOR.getValue(); fail(); } catch (IllegalStateException ex) {}