From 8ecde9af850cf3ef5c13ecc56e82fead3bde1d5f Mon Sep 17 00:00:00 2001 From: nathan Date: Sun, 19 Jul 2015 12:55:28 +0200 Subject: [PATCH] Fixed containsValue --- Dorkbox-Util/src/dorkbox/util/collections/ObjectIntMap.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dorkbox-Util/src/dorkbox/util/collections/ObjectIntMap.java b/Dorkbox-Util/src/dorkbox/util/collections/ObjectIntMap.java index 2648b41..6b93b2e 100644 --- a/Dorkbox-Util/src/dorkbox/util/collections/ObjectIntMap.java +++ b/Dorkbox-Util/src/dorkbox/util/collections/ObjectIntMap.java @@ -16,7 +16,6 @@ package dorkbox.util.collections; import com.esotericsoftware.kryo.util.ObjectMap; - import dorkbox.util.MathUtils; /** An unordered map where the values are ints. This implementation is a cuckoo hash map using 3 hashes, random walking, and a @@ -442,7 +441,7 @@ public class ObjectIntMap { public boolean containsValue (int value) { int[] valueTable = this.valueTable; for (int i = this.capacity + this.stashSize; i-- > 0;) { - if (valueTable[i] == value) { + if (keyTable[i] != null && valueTable[i] == value) { return true; } } @@ -479,7 +478,7 @@ public class ObjectIntMap { public K findKey (int value) { int[] valueTable = this.valueTable; for (int i = this.capacity + this.stashSize; i-- > 0;) { - if (valueTable[i] == value) { + if (keyTable[i] != null && valueTable[i] == value) { return this.keyTable[i]; } }