1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2016 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * Semantum Oy - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.utils.datastructures;
\r
14 import java.util.Map;
\r
17 * A common {@link Entry} implementation for both {@link ArrayMap}
\r
18 * and {@link InterlacedArrayMap}.
\r
20 * @author Tuukka Lehtonen
\r
22 * @param <K> key class
\r
23 * @param <V> value class
\r
25 class ArrayMapEntry<K, V> implements Map.Entry<K, V> {
\r
30 * Creates new entry.
\r
32 ArrayMapEntry(int h, K k, V v) {
\r
38 public final K getKey() {
\r
43 public final V getValue() {
\r
48 public final V setValue(V newValue) {
\r
55 public final boolean equals(Object o) {
\r
56 if (!(o instanceof Map.Entry<?, ?>))
\r
58 Map.Entry<?, ?> e = (Map.Entry<?, ?>)o;
\r
59 Object k1 = getKey();
\r
60 Object k2 = e.getKey();
\r
61 if (k1 == k2 || (k1 != null && k1.equals(k2))) {
\r
62 Object v1 = getValue();
\r
63 Object v2 = e.getValue();
\r
64 if (v1 == v2 || (v1 != null && v1.equals(v2)))
\r
71 public final int hashCode() {
\r
72 return (key==null ? 0 : key.hashCode()) ^
\r
73 (value==null ? 0 : value.hashCode());
\r
77 public final String toString() {
\r
78 return getKey() + "=" + getValue();
\r