Example #1
0
 /**
  * @param $key
  *
  * @return mixed
  * @throws TypeException when the $key is not the correct type.
  * @throws KeyException when the $key is not the correct type.
  */
 function get($key)
 {
     if (!$this->offsetExists($key)) {
         throw new KeyException();
     }
     /**
      * @var Pair $pair
      */
     $pair = $this->avl->get(new Pair($key, null));
     return $pair->second;
 }
Example #2
0
 function testGet()
 {
     $tree = new SplayTree();
     $tree->add(0);
     $tree->add(1);
     $tree->add(2);
     $expected = 1;
     $actual = $tree->get(1);
     $this->assertEquals($expected, $actual);
 }