Exemple #1
0
        /// <inheritdoc />
        public bool Remove(TKey key)
        {
            int hash = Math.Abs(key.GetHashCode()) % _size;

            if (HashMap[hash] is KeyValuePair <TKey, TValue> )
            {
                if (((KeyValuePair <TKey, TValue>)HashMap[hash]).Key.Equals(key))
                {
                    HashMap[hash] = null;
                    _elementCount--;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (HashMap[hash] is AVLNode)
            {
                AVLNode node = (AVLNode)HashMap[hash];

                return(AVLNode.FindRemoveKey(node, HashMap, hash, key, ref _elementCount));
            }

            return(false); // Redundant
        }
        /// <inheritdoc />
        public bool Remove(TKey key)
        {
            if (head == null)
            {
                return(false);
            }

            return(AVLNode.FindRemoveKey(head, this, key, ref count));
        }