public Object put(long key, Object value)
	{
		if (tc.isEntryEnabled()) Tr.entry(tc, "put", new Object[]{new Long(key), value, this});
		
		if (value == null)
		{
			if (tc.isEntryEnabled()) Tr.exit(tc, "put", "IllegalArgumentException");
			throw new IllegalArgumentException("Null is not a permitted value.");
		}
		
		// Find an empty bucket for the new value or
		// a bucket the contains an entry with the
		// same key.
		int hash = getHashForNewEntry(key);
		
		// Store the value previously held in the bucket
		// mapping DELETED to null so that it
		// can be returned to the caller.
		Object previous = _values[hash] == DELETED ? null : _values[hash];
		
		// Add the new value and key to the map.
		_values[hash] = value;
		_keys[hash] = key;        
		
		if (previous == null)
		{
			// This put resulted in a new entry being added to
			// the map rather than an existing entry being
			// updated. Increment the count of objects in the
			// map and rehash if necessary.
			_currentLoad++;
			
			if (_currentLoad == _resizeThreshold)
			{
                if (tc.isEntryEnabled()) Tr.entry(tc, "put", new Object[]{new Long(key), value, this});

				// The current load of the map means that it
				// has reached the desired loadFactor. Increase
				// the size of the map and rehash all the entries.
				
                // Take a copy of the map's contents so that we
                // can add them back in once it's been resized.
                long[] oldKeys = new long[_mapSize];
				Object[] oldValues = new Object[_mapSize];
                System.arraycopy(_keys, 0, oldKeys, 0, oldKeys.length);
                System.arraycopy(_values, 0, oldValues, 0, oldValues.length);
				
				// We know that the inital size of the map
                // is a power of 2 so, by doubling it, we
                // can increase the map's capacity and 
                // still be sure that it's size is a power
                // of two.
				_mapSize = (_mapSize * 2);

                if (tc.isDebugEnabled()) Tr.debug(tc, "mapSize = " + _mapSize);

                _resizeThreshold = (int)(((float)_mapSize) * ((float)_loadFactor) / 100f);

                if (tc.isDebugEnabled()) Tr.debug(tc, "resizeThreshold = " + _resizeThreshold);

				_values = new Object[_mapSize];
				_keys = new long[_mapSize];
				
				// Zero the count of objects in the map. This will
				// be incremented to the correct value as the
				// entries are added back into the resized map
				// below.
				_currentLoad = 0;
				
				// Loop through the old values adding live
				// entries back into the map.
				for (int i = 0; i < oldValues.length; i++)
				{
					Object oldValue = oldValues[i];
					
					if (oldValue != null && oldValue != DELETED)
					{
						put(oldKeys[i], oldValue);
					}
				}			
			}
		}
		
		if (tc.isEntryEnabled()) Tr.exit(tc, "put", previous);
		return previous;				
	}
public Object put ( long key , Object value ) { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "put" , new Object [ ] { new Long ( key ) , value , this } ) ; if ( value == null ) { if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "put" , "IllegalArgumentException" ) ; throw new IllegalArgumentException ( "Null is not a permitted value." ) ; } int hash = getHashForNewEntry ( key ) ; Object previous = _values [ hash ] == DELETED ? null : _values [ hash ] ; _values [ hash ] = value ; _keys [ hash ] = key ; if ( previous == null ) { _currentLoad ++ ; if ( _currentLoad == _resizeThreshold ) { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "put" , new Object [ ] { new Long ( key ) , value , this } ) ; long [ ] oldKeys = new long [ _mapSize ] ; Object [ ] oldValues = new Object [ _mapSize ] ; System . arraycopy ( _keys , 0 , oldKeys , 0 , oldKeys . length ) ; System . arraycopy ( _values , 0 , oldValues , 0 , oldValues . length ) ; _mapSize = ( _mapSize * 2 ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "mapSize = " + _mapSize ) ; _resizeThreshold = ( int ) ( ( ( float ) _mapSize ) * ( ( float ) _loadFactor ) / 100f ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "resizeThreshold = " + _resizeThreshold ) ; _values = new Object [ _mapSize ] ; _keys = new long [ _mapSize ] ; _currentLoad = 0 ; for ( int i = 0 ; i < oldValues . length ; i ++ ) { Object oldValue = oldValues [ i ] ; if ( oldValue != null && oldValue != DELETED ) { put ( oldKeys [ i ] , oldValue ) ; } } } } if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "put" , previous ) ; return previous ; }
Store the given value in the map, associating it with the given key. If the
map already contains an entry associated with the given key that entry will
be replaced.
@param key The key to associate with the entry
@param value The entry to be associated with the key
@return The entry replaced by this put operation, or null if no entry was replaced.
Null can also be returned if the given key was previously associated with a null value.