src/AnvilPacker/Util/Collections/DictionarySlim.cs
/// <summary>
/// Removes the entry if present with the specified key.
/// </summary>
/// <param name="key">Key to look for</param>
/// <returns>true if the key is present, false if it is not</returns>
Removes the entry if present with the specified key.
Removes the entry if present with the specified key .
public bool Remove(TKey key)
        {
            if (key == null) ThrowHelper.ThrowKeyArgumentNullException();
            Entry[] entries = _entries;
            int bucketIndex = key.GetHashCode() & (_buckets.Length - 1);
            int entryIndex = _buckets[bucketIndex] - 1;
            int lastIndex = -1;
            while (entryIndex != -1) {
                Entry candidate = entries[entryIndex];
                if (candidate.key.Equals(key)) {
                    if (lastIndex != -1) {   
                        entries[lastIndex].next = candidate.next;
                    } else {   
                        _buckets[bucketIndex] = candidate.next + 1;
                    }
                    entries[entryIndex] = default;
                    entries[entryIndex].next = -3 - _freeList; 
                    _freeList = entryIndex;
                    _count--;
                    return true;
                }
                lastIndex = entryIndex;
                entryIndex = candidate.next;
            }
            return false;
        }
public bool Remove ( TKey key ) { if ( key == null ) ThrowHelper . ThrowKeyArgumentNullException ( ) ; Entry [ ] entries = _entries ; int bucketIndex = key . GetHashCode ( ) & ( _buckets . Length - 1 ) ; int entryIndex = _buckets [ bucketIndex ] - 1 ; int lastIndex = - 1 ; while ( entryIndex != - 1 ) { Entry candidate = entries [ entryIndex ] ; if ( candidate . key . Equals ( key ) ) { if ( lastIndex != - 1 ) { entries [ lastIndex ] . next = candidate . next ; } else { _buckets [ bucketIndex ] = candidate . next + 1 ; } entries [ entryIndex ] = default ; entries [ entryIndex ] . next = - 3 - _freeList ; _freeList = entryIndex ; _count -- ; return true ; } lastIndex = entryIndex ; entryIndex = candidate . next ; } return false ; }
Removes the entry if present with the specified key.
Removes the entry if present with the specified key .
// Fixup preceding element in chain to point to next (if any) // Fixup bucket to new head (if any) // New head of free list
true if the key is present, false if it is not
true if the key is present false if it is not
key
TKey
Key to look for
Key to look for