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