/** * Retrieves the object stored under the given key from the map. * * @param key the key for which a value should be located. * @return the value or null, if the map did not contain a value for the key. */ public Object get( final Object key ) { final Object realKey = ensureKey( key ); final int hashKey = cleanHash( realKey.hashCode() ); final int index = hashKey & mask; final MapEntry existingEntry = backend[ index ]; if ( existingEntry == null ) { return null; } MapEntry colEntry = existingEntry; while ( colEntry != null ) { // The root entry exists and matches the current key. if ( colEntry.hashKey == hashKey && colEntry.key.equals( realKey ) ) { return colEntry.value; } colEntry = colEntry.collisionNext; } return null; }
/** * Checks, whether the map contains an entry for the key. * * @param key the key for which a value should be located. * @return true if the map contains a value for the key, false otherwise. */ public boolean containsKey( final Object key ) { final Object realKey = ensureKey( key ); final int hashKey = cleanHash( realKey.hashCode() ); final int index = hashKey & mask; final MapEntry existingEntry = backend[ index ]; if ( existingEntry == null ) { return false; } MapEntry colEntry = existingEntry; while ( colEntry != null ) { // The root entry exists and matches the current key. if ( colEntry.hashKey == hashKey && colEntry.key.equals( realKey ) ) { return true; } colEntry = colEntry.collisionNext; } return false; }
/** * Retrieves the object stored under the given key from the map. * * @param key the key for which a value should be located. * @return the value or null, if the map did not contain a value for the key. */ public Object get(final Object key) { final Object realKey = ensureKey(key); final int hashKey = cleanHash(realKey.hashCode()); final int index = hashKey & mask; final MapEntry existingEntry = backend[index]; if (existingEntry == null) { return null; } MapEntry colEntry = existingEntry; while (colEntry != null) { // The root entry exists and matches the current key. if (colEntry.hashKey == hashKey && colEntry.key.equals(realKey)) { return colEntry.value; } colEntry = colEntry.collisionNext; } return null; }
/** * Checks, whether the map contains an entry for the key. * * @param key the key for which a value should be located. * @return true if the map contains a value for the key, false otherwise. */ public boolean containsKey(final Object key) { final Object realKey = ensureKey(key); final int hashKey = cleanHash(realKey.hashCode()); final int index = hashKey & mask; final MapEntry existingEntry = backend[index]; if (existingEntry == null) { return false; } MapEntry colEntry = existingEntry; while (colEntry != null) { // The root entry exists and matches the current key. if (colEntry.hashKey == hashKey && colEntry.key.equals(realKey)) { return true; } colEntry = colEntry.collisionNext; } return false; }
final int hashKey = cleanHash( realKey.hashCode() );
final int hashKey = cleanHash(realKey.hashCode());
final int hashKey = cleanHash(realKey.hashCode());
final int hashKey = cleanHash( realKey.hashCode() );