Java Code Examples for java.util.Map.Entry#hashCode()
The following examples show how to use
java.util.Map.Entry#hashCode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropsContainerTest.java From linstor-server with GNU General Public License v3.0 | 6 votes |
@Test public void testMapEntryHashCode() { final Entry<String, String> entry = rootMap.entrySet().iterator().next(); final int origEntryHashCode = entry.hashCode(); final int origMapHashCode = rootMap.hashCode(); final String originalValue = entry.getValue(); entry.setValue("otherValue"); assertNotEquals(origEntryHashCode, entry.hashCode()); entry.setValue(originalValue); assertEquals(origMapHashCode, rootMap.hashCode()); }
Example 2
Source File: ScreenState.java From talkback with Apache License 2.0 | 5 votes |
@Override public int hashCode() { int h = 0; Iterator<Entry<Integer, AccessibilityWindowInfo>> iterator = idToWindowInfoMap.entrySet().iterator(); while (iterator.hasNext()) { Entry<Integer, AccessibilityWindowInfo> entry = iterator.next(); h += entry.hashCode() ^ Objects.hashCode(getWindowTitle(entry.getKey())); } return h; }
Example 3
Source File: AbstractMap.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * 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 * {@code entrySet()} view. This ensures that {@code m1.equals(m2)} * implies that {@code m1.hashCode()==m2.hashCode()} for any two maps * {@code m1} and {@code m2}, as required by the general contract of * {@link Object#hashCode}. * * @implSpec * This implementation iterates over {@code entrySet()}, calling * {@link 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 Map.Entry#hashCode() * @see Object#equals(Object) * @see Set#equals(Object) */ public int hashCode() { int h = 0; for (Entry<K, V> entry : entrySet()) h += entry.hashCode(); return h; }
Example 4
Source File: AbstractMap.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * 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 * {@code entrySet()} view. This ensures that {@code m1.equals(m2)} * implies that {@code m1.hashCode()==m2.hashCode()} for any two maps * {@code m1} and {@code m2}, as required by the general contract of * {@link Object#hashCode}. * * @implSpec * This implementation iterates over {@code entrySet()}, calling * {@link 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 Map.Entry#hashCode() * @see Object#equals(Object) * @see Set#equals(Object) */ public int hashCode() { int h = 0; for (Entry<K, V> entry : entrySet()) h += entry.hashCode(); return h; }