public function removeEntity(HasId $entity)
    {
        $key = $entity->getId();

        if ($key !== null) {
            unset($this->pool[$this->map[$key]]);
            $this->removeIndexEntry($key);
        }
    }