Remove a key

@param mixed $key The key
@param ComparatorInterface $comparator The comparator function

@return  TreeNode  The new root
171444
public function remove($key, $comparator)
    {
        $cmp = $comparator->compare($key, $this->fKey);

        if ($cmp < 0) {
            if ($this->information & 2) {
                $leftBalance = $this->left->information & ~3;
                $this->left = $this->left->remove($key, $comparator);

                if (!($this->information & 2) || $leftBalance != 0 && ($this->left->information & ~3) == 0) {
                    return $this->incBalance();
                }
            }
        } elseif ($cmp > 0) {
            if ($this->information & 1) {
                $rightBalance = $this->right->information & ~3;
                $this->right = $this->right->remove($key, $comparator);

                if (!($this->information & 1) || $rightBalance != 0 && ($this->right->information & ~3) == 0) {
                    return $this->decBalance();
                }
            }
        } else {
            if ($this->information & 1) {
                $rightBalance = $this->right->information & ~3;
                $this->right = $this->right->pullUpLeftMost();

                if (!($this->information & 1) || $rightBalance != 0 && ($this->right->information & ~3) == 0) {
                    return $this->decBalance();
                }
            } else {
                $left = $this->left;
                $right = $this->right;

                if ($this->information & 2) {
                    $left->right = $right;

                    return $left;
                } else {
                    if ($left && $left->right === $this) {
                        $left->information &= ~ 1;

                        return $right;
                    } elseif ($right && $right->left === $this) {
                        $right->information &= ~ 2;

                        return $left;
                    } else {
                        return null;
                    }
                }
            }
        }

        return $this;
    }
9001
public function remove($key, $when = self::NEXT)
    {
        $deleteWhen = $when == self::ALL ? self::$when : (array) $when;
        foreach ($deleteWhen as $when) {
            $this->set($key, null, $when);
        }

        return $this;
    }
85977
public function trim($key = null)
    {
        if (null === $key) {
            foreach ($this->all() as $key => $value) {
                if (is_scalar($value)) {
                    $this->set($key, trim($value));
                }
            }
        } else {
            $value = $this->get($key);
            if (is_scalar($value)) {
                $this->set($key, trim($value));
            }
        }

        return $this;
    }
1129730
Node<K, V> find(K key, boolean create) {
    Comparator<? super K> comparator = this.comparator;
    Node<K, V> nearest = root;
    int comparison = 0;

    if (nearest != null) {
      // Micro-optimization: avoid polymorphic calls to Comparator.compare().
      @SuppressWarnings("unchecked") // Throws a ClassCastException below if there's trouble.
          Comparable<Object> comparableKey = (comparator == NATURAL_ORDER)
          ? (Comparable<Object>) key
          : null;

      while (true) {
        comparison = (comparableKey != null)
            ? comparableKey.compareTo(nearest.key)
            : comparator.compare(key, nearest.key);

        // We found the requested key.
        if (comparison == 0) {
          return nearest;
        }

        // If it exists, the key is in a subtree. Go deeper.
        Node<K, V> child = (comparison < 0) ? nearest.left : nearest.right;
        if (child == null) {
          break;
        }

        nearest = child;
      }
    }

    // The key doesn't exist in this tree.
    if (!create) {
      return null;
    }

    // Create the node and add it to the tree or the table.
    Node<K, V> header = this.header;
    Node<K, V> created;
    if (nearest == null) {
      // Check that the value is comparable if we didn't do any comparisons.
      if (comparator == NATURAL_ORDER && !(key instanceof Comparable)) {
        throw new ClassCastException(key.getClass().getName() + " is not Comparable");
      }
      created = new Node<K, V>(nearest, key, header, header.prev);
      root = created;
    } else {
      created = new Node<K, V>(nearest, key, header, header.prev);
      if (comparison < 0) { // nearest.key is higher
        nearest.left = created;
      } else { // comparison > 0, nearest.key is lower
        nearest.right = created;
      }
      rebalance(nearest, true);
    }
    size++;
    modCount++;

    return created;
  }
659681
private void comparatorDecreaseKey(Node<K, V> n, K newKey) {
        int c = comparator.compare(newKey, n.key);
        if (c > 0) {
            throw new IllegalArgumentException("Keys can only be decreased!");
        }
        n.key = newKey;
        if (c == 0) {
            return;
        }

        if (n.next == null) {
            throw new IllegalArgumentException("Invalid handle!");
        }

        // if not root and heap order violation
        Node<K, V> y = n.parent;
        if (y != null && comparator.compare(n.key, y.key) < 0) {
            cut(n, y);
            root.mark = false;
            cascadingRankChange(y);
            if (comparator.compare(n.key, root.key) < 0) {
                root = link(root, n);
            } else {
                link(n, root);
            }
        }
    }
427039
public function remove($key) {
		$key = $this->extractKey($key);
		if (isset($this->collection[$key])) {
			$element = $this->collection[$key];
			unset($this->collection[$key]);
			
			return $element;
		}
	}
1332279
public function delete($key)
    {
        Arguments::define($this->getKeyType())->check($key);

        $cloned = array_merge($this->value);

        unset($cloned[$key]);

        return static::of($cloned);
    }
1246891
public function remove($key)
    {
        if (isset($this->fields[$key])) {
            unset($this->fields[$key]);
        }
        return $this;
    }
598121
public function remove($key)
    {
        if (!is_string($key) && !is_numeric($key)) {
            throw new InvalidArgumentException(
                'Invalid key name given! Key config to remove must be as a string!'
            );
        }

        if (!$this->exist($key)) {
            return;
        }

        if (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $key, $matches)) > 1) {
            $firstKey = reset($matches[0]);
            $keyName  = $firstKey;
            $tmp      = $this->collection[$keyName];
            if (!is_array($tmp)) {
                return;
            }
            array_shift($matches[0]);
            $unsetPosition = 0;
            foreach ($matches[0] as $keyNum => $keyName) {
                $keyName = trim($keyName, '[]');
                if ($unsetPosition <> $keyNum &&
                    (!is_array($tmp) || ! array_key_exists($keyName, $tmp))
                ) {
                    return;
                }

                $unsetPosition++;
                $tmp = $tmp[$keyName];
            }

            $tmp = $this->collection[$firstKey];
            $currentUnsetPosition = 0;
            // binding anonymous function to handle array reference
            $recursiveUnset = function (
                &$array,
                $unwanted_key
            ) use (
                $unsetPosition,
                &$currentUnsetPosition,
                &$recursiveUnset
            ) {
                $currentUnsetPosition++;
                if ($unsetPosition !== $currentUnsetPosition) {
                    if (array_key_exists($unwanted_key, $array)) {
                        unset($array[$unwanted_key]);
                    }
                    // stop
                    return;
                }
                foreach ($array as &$value) {
                    if (is_array($value)) {
                        $recursiveUnset($value, $unwanted_key);
                    }
                }
            };

            // call closure to binding reference
            $recursiveUnset($tmp, $keyName);
            $this->collection[$firstKey] = $tmp;
            unset($tmp);
            return; // stop
        }

        unset($this->collection[$key]);
    }
891460
public function remove($key) {
        $this->_data = Hash::remove($this->_data, $key);

        return $this;
    }
955089
protected function nodeRemove($key, RedBlackNode $node): ?RedBlackNode
    {
        $comp = $this->comparator->compare($key, $node->key());
        if ($comp < 0) {
            $node = $this->nodeRemoveLeft($key, $node);
        } else {
            if ($this->isRed($node->left())) {
                $node = $this->rotateRight($node);
            }
            if ($comp === 0 && $node->right() === null) {
                return null;
            }
            $node = $this->nodeRemoveRight($key, $node);
        }

        return $this->balanceOnRemove($node);
    }
1306983
public static void sortNode(TreeNode node, Comparator comparator) {
        TreeNodeList children = (TreeNodeList) node.getChildren();

        if (children != null && !children.isEmpty()) {
            Object[] childrenArray = children.toArray();
            Arrays.sort(childrenArray, comparator);
            for (int i = 0; i < childrenArray.length; i++) {
                children.setSibling(i, (TreeNode) childrenArray[i]);
            }

            for (int i = 0; i < children.size(); i++) {
                sortNode(children.get(i), comparator);
            }
        }
    }
103208
public function ksort(callable $comparator = null)
    {
        if ($comparator) {
            usort($this->pairs, function($a, $b) use ($comparator) {
                return $comparator($a->key, $b->key);
            });

        } else {
            usort($this->pairs, function($a, $b) {
                return $a->key <=> $b->key;
            });
        }
    }
390301
public final function remove($key)
    {
        $previous = $this->get($key);

        if (isset($this->_map[$key])) {

            unset($this->_map[$key]);
        }

        return $previous;
    }
165033
function del($key)
    {
        if ($this->has($key)) {
            $p = &$this->__attainInternalPointer();
            unset($p[$key]);
        }

        return $this;
    }
6123
public function remove( $key )
	{
		if( empty( $key ) )																		//  no Key given
			throw new InvalidArgumentException( 'Key must not be empty.' );						//  throw Exception
		if( isset( $this->pairs[$key] ) )														//  Key is set on its own
			unset( $this->pairs[$key] );														//  remove Pair
		else																					//  Key has not been found
		{
			$key		.= $this->divider;														//  prepare Prefix Key to seach for
			foreach( $this->pairs as $pairKey => $pairValue )									//  iterate all stores Pairs
			{
				if( $pairKey[0] !== $key[0] )													//  precheck for Performance
					continue;																	//  skip Pair
				if( strpos( $pairKey, $key ) === 0 )											//  Prefix Key is found
					unset( $this->pairs[$pairKey] );											//  remove Pair
			}
		}
	}
1122734
public function isEqualTo(ClassName $className, Comparator $comparator = null)
    {
        if (null === $comparator) {
            $comparator = new Comparator;
        }

        return $comparator->equals($this, $className);
    }