src/Datastructure/Maps/HashMap.php
public function remove($key): bool {
        //get the corresponding index to key
        $arrayIndex = $this->getBucketIndex($key);

        /*
         *if the array index is not available in the
         * bucket list, end the method and return true.
         * True due to the operation was successful, meaning
         * that $key is not in the list.
         * False would indicate that there was an error
         * and the node is still in the list
         */
        if (!isset($this->bucket[$arrayIndex])) {
            return true;
        }
        /** @var SinglyLinkedList $list */
        $list = $this->bucket[$arrayIndex];
        /** @var Node $head */
        $head = $list->getHead();
        /*
         * there is one special case for the HashMap:
         * if there is only one node in the bucket, then
         * check if the nodes key equals to the key that
         * should be deleted.
         * If this is the case, set the bucket to null
         * because the only one node is removed.
         * If this is not the key, return false as there
         * is no node to remove.
         */
        if ($list->size() == 1 && $head->getKey() === $key) {
            //$this->bucket[$arrayIndex] = null;
            unset($this->bucket[$arrayIndex]);
            return true;
        }
        return $list->remove($key);
    }
public function remove($key): bool {
        //get the corresponding index to key
        $arrayIndex = $this->getBucketIndex($key);

        /*
         *if the array index is not available in the
         * bucket list, end the method and return true.
         * True due to the operation was successful, meaning
         * that $key is not in the list.
         * False would indicate that there was an error
         * and the node is still in the list
         */
        if (!isset($this->bucket[$arrayIndex])) {
            return true;
        }
        /** @var SinglyLinkedList $list */
        $list = $this->bucket[$arrayIndex];
        /** @var Node $head */
        $head = $list->getHead();
        /*
         * there is one special case for the HashMap:
         * if there is only one node in the bucket, then
         * check if the nodes key equals to the key that
         * should be deleted.
         * If this is the case, set the bucket to null
         * because the only one node is removed.
         * If this is not the key, return false as there
         * is no node to remove.
         */
        if ($list->size() == 1 && $head->getKey() === $key) {
            //$this->bucket[$arrayIndex] = null;
            unset($this->bucket[$arrayIndex]);
            return true;
        }
        return $list->remove($key);
    }
public function remove ( $ key ) : bool { //get the corresponding index to key $ arrayIndex = $ this -> getBucketIndex ( $ key ) ; /*
         *if the array index is not available in the
         * bucket list, end the method and return true.
         * True due to the operation was successful, meaning
         * that $key is not in the list.
         * False would indicate that there was an error
         * and the node is still in the list
         */ if ( ! isset ( $ this -> bucket [ $ arrayIndex ] ) ) { return true ; } /** @var SinglyLinkedList $list */ $ list = $ this -> bucket [ $ arrayIndex ] ; /** @var Node $head */ $ head = $ list -> getHead ( ) ; /*
         * there is one special case for the HashMap:
         * if there is only one node in the bucket, then
         * check if the nodes key equals to the key that
         * should be deleted.
         * If this is the case, set the bucket to null
         * because the only one node is removed.
         * If this is not the key, return false as there
         * is no node to remove.
         */ if ( $ list -> size ( ) == 1 && $ head -> getKey ( ) === $ key ) { //$this->bucket[$arrayIndex] = null; unset ( $ this -> bucket [ $ arrayIndex ] ) ; return true ; } return $ list -> remove ( $ key ) ; }
removes a node by a given key

@param $key
@return bool
@throws \doganoo\PHPAlgorithms\Common\Exception\InvalidKeyTypeException
@throws \doganoo\PHPAlgorithms\Common\Exception\UnsupportedKeyTypeException
removes a node by a given key