/** * @link http://php.net/manual/en/arrayaccess.offsetexists.php * * @param mixed $offset * * @return bool */ function offsetExists($offset) { return $this->avl->contains(new Pair($offset, null)); }
function testContains() { $object = new SplayTree(); $this->assertFalse($object->contains(1)); $object->add(0); $this->assertFalse($object->contains(1)); $object->add(2); $this->assertFalse($object->contains(1)); $object->add(1); $this->assertTrue($object->contains(1)); $expected = new BinaryTree(1); $expected->setLeft(new BinaryTree(0)); $expected->setRight(new BinaryTree(2)); $actual = $object->toBinaryTree(); $this->assertEquals($expected, $actual); }