Beispiel #1
0
 /**
  * @param string $key
  * @param mixed  $value
  *
  * @return void
  */
 public function insert($key, $value)
 {
     $this->fixLength($key, $value);
     $hash = $this->hash($key);
     $key = str_pad($key, $this->dataLength, ' ');
     $value = str_pad($value, $this->dataLength, ' ');
     $this->storage->write($key . $value, $this->position($hash));
 }
Beispiel #2
0
 /**
  * @param string $key
  * @param string $value
  * @param int    $parent
  *
  * @return int
  */
 private function store($key, $value, $parent = -1)
 {
     $address = $this->nextAddress++;
     $node = $this->make($key, $value, $parent);
     $this->storage->write($node, $address * $this->fullLength);
     if ($parent < 0) {
         $this->top = $address;
     }
     return $address;
 }