summaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-04-21 18:48:04 +0200
committerMichael Bien <[email protected]>2010-04-21 18:48:04 +0200
commit88112252043c41b5bb3e232d2a3c65dba2188c31 (patch)
tree3445b634416adc7585fbe62780ccd3f148d5cf70 /src/java
parentbce53b52c8638729750c4286dbc04cb14329fd34 (diff)
added getKeyNotFoundValue() and some javadoc to IntIntHashMap.
Diffstat (limited to 'src/java')
-rw-r--r--src/java/com/jogamp/common/util/IntIntHashMap.java49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/java/com/jogamp/common/util/IntIntHashMap.java b/src/java/com/jogamp/common/util/IntIntHashMap.java
index 1288ad4..1f99944 100644
--- a/src/java/com/jogamp/common/util/IntIntHashMap.java
+++ b/src/java/com/jogamp/common/util/IntIntHashMap.java
@@ -88,19 +88,6 @@ 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;) {
@@ -124,6 +111,10 @@ public class /*name*/IntIntHashMap/*name*/ {
return false;
}
+ /**
+ * Returns the value to which the specified key is mapped,
+ * or {@link #getKeyNotFoundValue} if this map contains no mapping for the key.
+ */
// @SuppressWarnings(value="cast")
public /*value*/int/*value*/ get(/*key*/int/*key*/ key) {
int index = (int) (key & mask);
@@ -135,6 +126,10 @@ public class /*name*/IntIntHashMap/*name*/ {
return keyNotFoundValue;
}
+ /**
+ * Maps the key to the specified value. If a mapping to this key already exists,
+ * the previous value will be returned (otherwise {@link #getKeyNotFoundValue}).
+ */
// @SuppressWarnings(value="cast")
public /*value*/int/*value*/ put(/*key*/int/*key*/ key, /*value*/int/*value*/ value) {
int index = (int) (key & mask);
@@ -175,6 +170,10 @@ public class /*name*/IntIntHashMap/*name*/ {
return keyNotFoundValue;
}
+ /**
+ * Removes the key-value mapping from this map.
+ * Returns the priviously mapped value or {@link #getKeyNotFoundValue} if no such mapping exists.
+ */
// @SuppressWarnings(value="cast")
public /*value*/int/*value*/ remove(/*key*/int/*key*/ key) {
int index = (int) (key & mask);
@@ -209,6 +208,30 @@ public class /*name*/IntIntHashMap/*name*/ {
size = 0;
}
+ /**
+ * 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
+ * @see #get
+ * @see #put
+ */
+ public /*value*/int/*value*/ setKeyNotFoundValue(/*value*/int/*value*/ newKeyNotFoundValue) {
+ /*value*/int/*value*/ t = keyNotFoundValue;
+ keyNotFoundValue = newKeyNotFoundValue;
+ return t;
+ }
+
+ /**
+ * Returns the value which is returned if no value has been found for the specified key.
+ * @see #get
+ * @see #put
+ */
+ public /*value*/int/*value*/ getKeyNotFoundValue() {
+ return keyNotFoundValue;
+ }
+
private final static class Entry {
private final /*key*/int/*key*/ key;