diff options
author | Sven Gothel <[email protected]> | 2010-04-19 01:19:06 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-04-19 01:19:06 +0200 |
commit | c7630f35befa1b8dbd365984f08c4efbc04488c1 (patch) | |
tree | ecaa3cbd0dbee4fdf145e7f559343dff3d4a31b6 /src | |
parent | 012945e169956ab1e227020a07e4f1b602c9dec7 (diff) |
Added keyNotFoundValue semantics, for primitve types it defaults to -1 now.
Diffstat (limited to 'src')
-rw-r--r-- | src/java/com/jogamp/common/util/IntIntHashMap.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/java/com/jogamp/common/util/IntIntHashMap.java b/src/java/com/jogamp/common/util/IntIntHashMap.java index f9b0f2d..1288ad4 100644 --- a/src/java/com/jogamp/common/util/IntIntHashMap.java +++ b/src/java/com/jogamp/common/util/IntIntHashMap.java @@ -58,6 +58,7 @@ public class /*name*/IntIntHashMap/*name*/ { private int mask; private int capacity; private int threshold; + private /*value*/int/*value*/ keyNotFoundValue = /*null*/-1/*null*/; public /*name*/IntIntHashMap/*name*/() { this(16, 0.75f); @@ -87,6 +88,19 @@ public class /*name*/IntIntHashMap/*name*/ { this.mask = capacity - 1; } + /** + * Sets the new key not found value. + * For primitive types (int, long) the default is -1, + * for Object types, the default is null. + * + * @return the previous key not found value + */ + public /*value*/int/*value*/ setKeyNotFoundValue(/*value*/int/*value*/ newKeyNotFoundValue) { + /*value*/int/*value*/ t = keyNotFoundValue; + keyNotFoundValue = newKeyNotFoundValue; + return t; + } + public boolean containsValue(/*value*/int/*value*/ value) { Entry[] table = this.table; for (int i = table.length; i-- > 0;) { @@ -118,7 +132,7 @@ public class /*name*/IntIntHashMap/*name*/ { return e.value; } } - return /*null*/0/*null*/; + return keyNotFoundValue; } // @SuppressWarnings(value="cast") @@ -158,7 +172,7 @@ public class /*name*/IntIntHashMap/*name*/ { threshold = (int) (newCapacity * loadFactor); mask = capacity - 1; } - return /*null*/0/*null*/; + return keyNotFoundValue; } // @SuppressWarnings(value="cast") @@ -180,7 +194,7 @@ public class /*name*/IntIntHashMap/*name*/ { prev = e; e = next; } - return /*null*/0/*null*/; + return keyNotFoundValue; } public int size() { |