Java Code Examples for java.util.Map.Entry.hashCode()

The following are Jave code examples for showing how to use hashCode() of the java.util.Map.Entry class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: myfaces-trinidad   File: CopyOnWriteArrayMap.java   View Source Code Vote up 5 votes
@Override
public int hashCode()
{
  int hash = 0;

  ConcurrentEntry<K,V>[] entries = _entries;

  for (Entry<K,V> entry : entries)
  {
    hash += entry.hashCode();
  }

  return hash;
}
 
Example 2
Project: java-kdtree   File: Tree.java   View Source Code Vote up 5 votes
@Override
public int hashCode() {
	int result = 31 * size + dimensions;
	for (Entry<K, V> entry : this) {
		result = 31 * result + entry.hashCode();
	}
	return result;
}
 
Example 3
Project: openjdk-jdk10   File: AbstractMap.java   View Source Code Vote up 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;
}