Ejemplo n.º 1
0
 /**
  * Add value
  *
  * @param $value
  * @return mixed
  */
 public function add($value)
 {
     $node = $this->nodeFactory->create($value);
     $this->length++;
     if (!$this->current) {
         $this->current = $node;
         $this->last = $node;
     } else {
         $this->last->setRight($node);
         $this->last = $node;
     }
 }
Ejemplo n.º 2
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;
     }
 }