/** * Removes an entry from the table. * @return the value or null */ public Object remove(Object o1, Object o2) { int hash = hashCode(o1, o2) & 0x7FFFFFFF; int index = hash % table.length; Entry e = table[index]; if (e == null) { return null; } if (e.hash == hash && e.match(o1, o2)) { table[index] = e.next; count--; return e.value; } Entry prev = e; for (e = e.next; e != null; prev = e, e = e.next) { if (e.hash == hash && e.match(o1, o2)) { prev.next = e.next; count--; return e.value; } } return null; }
/** * Removes an entry from the table. * @return the value or null */ public Object remove(Object o1, Object o2) { int hash = hashCode(o1, o2) & 0x7FFFFFFF; int index = hash % table.length; Entry e = table[index]; if (e == null) { return null; } if (e.hash == hash && e.match(o1, o2)) { table[index] = e.next; count--; return e.value; } Entry prev = e; for (e = e.next; e != null; prev = e, e = e.next) { if (e.hash == hash && e.match(o1, o2)) { prev.next = e.next; count--; return e.value; } } return null; }
/** * Puts a value in the table. * @return the old value or null */ public Object put(Object o1, Object o2, Object value) { int hash = hashCode(o1, o2) & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if ((e.hash == hash) && e.match(o1, o2)) { Object 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; } Entry e = new Entry(hash, o1, o2, value, table[index]); table[index] = e; return null; }
/** * Puts a value in the table. * @return the old value or null */ public Object put(Object o1, Object o2, Object value) { int hash = hashCode(o1, o2) & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if ((e.hash == hash) && e.match(o1, o2)) { Object 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; } Entry e = new Entry(hash, o1, o2, value, table[index]); table[index] = e; return null; }
/** * Removes an entry from the table. * @return the value or null */ public Object remove(Object o1, Object o2) { int hash = hashCode(o1, o2) & 0x7FFFFFFF; int index = hash % table.length; Entry e = table[index]; if (e == null) { return null; } if (e.hash == hash && e.match(o1, o2)) { table[index] = e.next; count--; return e.value; } Entry prev = e; for (e = e.next; e != null; prev = e, e = e.next) { if (e.hash == hash && e.match(o1, o2)) { prev.next = e.next; count--; return e.value; } } return null; }
/** * Puts a value in the table. * @return the old value or null */ public Object put(Object o1, Object o2, Object value) { int hash = hashCode(o1, o2) & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if ((e.hash == hash) && e.match(o1, o2)) { Object 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; } Entry e = new Entry(hash, o1, o2, value, table[index]); table[index] = e; return null; }
/** * Creates a new DoublyIndexedTable initialized to contain all of * the entries of the specified other DoublyIndexedTable. */ public DoublyIndexedTable(DoublyIndexedTable other) { initialCapacity = other.initialCapacity; table = new Entry[other.table.length]; for (int i = 0; i < other.table.length; i++) { Entry newE = null; Entry e = other.table[i]; while (e != null) { newE = new Entry(e.hash, e.key1, e.key2, e.value, newE); e = e.next; } table[i] = newE; } count = other.count; }
/** * Creates a new DoublyIndexedTable initialized to contain all of * the entries of the specified other DoublyIndexedTable. */ public DoublyIndexedTable(DoublyIndexedTable other) { initialCapacity = other.initialCapacity; table = new Entry[other.table.length]; for (int i = 0; i < other.table.length; i++) { Entry newE = null; Entry e = other.table[i]; while (e != null) { newE = new Entry(e.hash, e.key1, e.key2, e.value, newE); e = e.next; } table[i] = newE; } count = other.count; }
/** * Creates a new DoublyIndexedTable initialized to contain all of * the entries of the specified other DoublyIndexedTable. */ public DoublyIndexedTable(DoublyIndexedTable other) { initialCapacity = other.initialCapacity; table = new Entry[other.table.length]; for (int i = 0; i < other.table.length; i++) { Entry newE = null; Entry e = other.table[i]; while (e != null) { newE = new Entry(e.hash, e.key1, e.key2, e.value, newE); e = e.next; } table[i] = newE; } count = other.count; }
/** * Gets the value of an entry * @return the value or null */ public Object get(Object o1, Object o2) { int hash = hashCode(o1, o2) & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if ((e.hash == hash) && e.match(o1, o2)) { return e.value; } } return null; }
/** * Gets the value of an entry * @return the value or null */ public Object get(Object o1, Object o2) { int hash = hashCode(o1, o2) & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if ((e.hash == hash) && e.match(o1, o2)) { return e.value; } } return null; }
/** * Gets the value of an entry * @return the value or null */ public Object get(Object o1, Object o2) { int hash = hashCode(o1, o2) & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if ((e.hash == hash) && e.match(o1, o2)) { return e.value; } } return null; }