/** * Sets a new value for the given variable */ public void put( String key, int 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.equals( key ) ) { e.value = value; return; } } // 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; }
/** * Sets a new value for the given variable */ public void put( String key, int 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.equals( key ) ) { e.value = value; return; } } // 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; }
/** * Sets a new value for the given variable */ public void put( String key, int 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.equals( key ) ) { e.value = value; return; } } // 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; }