public V remove(Object key)
    {
        // Check if the key is in the map
        Integer index = keyToIndex.get(key);

        if (index == null)
        {
            return null;
        }

        // Leave the data in the array but remove its key
        keyToIndex.remove(key);
        keySet.remove(key);

        // Remove the data from the array
        V removedValue = data.remove(index.intValue());

        // Go through the whole key to index map reducing by one the value of any indexes greater that the removed index
        for (K nextKey : keyToIndex.keySet())
        {
            Integer nextIndex = keyToIndex.get(nextKey);

            if (nextIndex > index)
            {
                keyToIndex.put(nextKey, nextIndex - 1);
            }
        }

        // Return the removed object
        return removedValue;
    }
public V remove(Object key)
    {
        
        Integer index = keyToIndex.get(key);

        if (index == null)
        {
            return null;
        }

        
        keyToIndex.remove(key);
        keySet.remove(key);

        
        V removedValue = data.remove(index.intValue());

        
        for (K nextKey : keyToIndex.keySet())
        {
            Integer nextIndex = keyToIndex.get(nextKey);

            if (nextIndex > index)
            {
                keyToIndex.put(nextKey, nextIndex - 1);
            }
        }

        
        return removedValue;
    }
public V remove ( Object key ) { // Check if the key is in the map Integer index = keyToIndex . get ( key ) ; if ( index == null ) { return null ; } // Leave the data in the array but remove its key keyToIndex . remove ( key ) ; keySet . remove ( key ) ; // Remove the data from the array V removedValue = data . remove ( index . intValue ( ) ) ; // Go through the whole key to index map reducing by one the value of any indexes greater that the removed index for ( K nextKey : keyToIndex . keySet ( ) ) { Integer nextIndex = keyToIndex . get ( nextKey ) ; if ( nextIndex > index ) { keyToIndex . put ( nextKey , nextIndex - 1 ) ; } } // Return the removed object return removedValue ; }
Removes the mapping for the specified key from this map if present.

@param  key The key to remove from this map.

@return The value that stored at that key, or null if there was none.
Removes the mapping for the specified key from this map if present .