示例#1
0
 /**
  * Add value
  *
  * @param string $key
  * @param $value
  * @return mixed
  */
 public function add(string $key, $value)
 {
     $item = $this->itemFactory->create($key, $value);
     $node = $this->nodeFactory->create($item);
     $this->length++;
     if (!$this->first) {
         $this->first = $node;
         $this->current = $node;
         $this->last = $node;
     } else {
         $this->last->setRight($node);
         $node->setLeft($this->last);
         $this->last = $node;
     }
 }
示例#2
0
 /**
  * @param string $key
  * @return int
  */
 private function createIndex(string $key) : int
 {
     return $this->itemFactory->create($key, null)->getHashCode();
 }