public function put($key, $value): bool {
        if ($this->hashMap->containsKey($key)) {
            $node = $this->getNodeFromHead($key);
            $node->setKey($key);
            $node->setValue($value);
            $this->unset($node);
            $this->updateHead($node);
            return true;
        }
        if ($this->hashMap->size() >= $this->capacity) {
            $end = $this->getEnd();
            if (null !== $end) {
                $this->unset($end);
                $this->hashMap->remove($end->getKey());
            }
        }
        $node = new Node();
        $node->setKey($key);
        $node->setValue($value);
        $this->updateHead($node);
        $this->hashMap->add($key, $value);
        return true;
    }