/** * Decrements the value associated with the given key. */ public int dec(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value--; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, -1, table[index]); return 0; }
/** * Increments the value associated with the given key. */ public int inc(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value++; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, 1, table[index]); return 0; }
/** * Decrements the value associated with the given key. */ public int dec(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value--; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, -1, table[index]); return 0; }
/** * Sets the value associated with the given key. */ public int put(Object key, int value) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { int old = e.value; e.value = value; return old; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, value, table[index]); return 0; }
/** * Sets the value associated with the given key. */ public int put(Object key, int value) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { int old = e.value; e.value = value; return old; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, value, table[index]); return 0; }
/** * Increments the value associated with the given key. */ public int inc(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value++; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, 1, table[index]); return 0; }
/** * Decrements the value associated with the given key. */ public int dec(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value--; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, -1, table[index]); return 0; }
/** * Increments the value associated with the given key. */ public int inc(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value++; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, 1, table[index]); return 0; }
/** * Sets the value associated with the given key. */ public int put(Object key, int value) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { int old = e.value; e.value = value; return old; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, value, table[index]); return 0; }