/** * 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; }
/** * 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; }