function test__constructException() { $this->setExpectedException('\\Collections\\StateException'); $tree = new SplayTree(); $tree->add(1); new SortedSet(null, $tree); }
{ global $splayTree; // Insert new node with a unique key. $key = null; do { $key = GenerateKey(); } while (!is_null($splayTree->find($key))); $payload = GeneratePayloadTree(kSplayTreePayloadDepth, (string) $key); $splayTree->insert($key, $payload); return $key; } $SplaySetup = function () { global $splayTree, $performance, $splaySampleTimeStart; // Check if the platform has the performance.now high resolution timer. // If not, throw exception and quit. $splayTree = new SplayTree(); $splaySampleTimeStart = $performance['now'](); for ($i = 0; $i < kSplayTreeSize; $i++) { InsertNewNode(); if (($i + 1) % 20 == 19) { SplayUpdateStats($performance['now']()); } } }; $SplayTearDown = function () { global $splayTree; // Allow the garbage collector to reclaim the memory // used by the splay tree no matter how we exit the // tear down function. $keys = $splayTree->exportKeys(); $splayTree = null;
/** * @link http://php.net/manual/en/iteratoraggregate.getiterator.php * @return SortedMapIterator */ function getIterator() { return new SortedMapIterator(new InOrderIterator($this->avl->toBinaryTree(), $this->avl->count()), $this->avl->count()); }
/** * @expectedException \Collections\StateException */ function testSetCompareNotEmpty() { $tree = new SplayTree(); $tree->add(0); $tree->setCompare(function ($a, $b) { }); }