/** * Sets a new value for the given variable * @return the old value or null */ public Object put( String key, Object value ) { int hash = key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for ( Entry e = table[ index ]; e != null; e = e.next ) { if ( ( e.hash == hash ) && e.key == key ) { 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, key, value, table[ index ] ); table[ index ] = e; return null; }
/** * Sets a new value for the given variable * @return the old value or null */ public Object put( String key, Object value ) { int hash = key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for ( Entry e = table[ index ]; e != null; e = e.next ) { if ( ( e.hash == hash ) && e.key == key ) { 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, key, value, table[ index ] ); table[ index ] = e; return null; }
/** * Sets a new value for the given variable * @return the old value or null */ public Object put( String key, Object value ) { int hash = key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for ( Entry e = table[ index ]; e != null; e = e.next ) { if ( ( e.hash == hash ) && e.key == key ) { 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, key, value, table[ index ] ); table[ index ] = e; return null; }