Skip to content

Commit

Permalink
Merge branch 'features/splay-tree-extra'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramy-Badr-Ahmed committed Oct 11, 2024
2 parents 6f4bead + 25b80d3 commit d9346ee
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/DataStructures/SplayTreeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,16 @@ public function testDeleteMultipleKeys()
$splayTree = new SplayTree($arrayData);
$treeSize = $splayTree->size();

// pick randomly a number of nodes to delete within the arrayData
$numberOfNodesToDelete = rand(1, count($arrayData));

// pick randomly some nodes to delete by their keys
$randomNodesToDelete = array_rand($arrayData, $numberOfNodesToDelete);

$randomNodesToDelete = is_array($randomNodesToDelete)
? $randomNodesToDelete
: [$randomNodesToDelete];

for ($i = 0; $i < count($randomNodesToDelete); $i++) {
$splayTree->delete($randomNodesToDelete[$i]);
$isFound = $splayTree->isFound($randomNodesToDelete[$i]);
Expand Down

0 comments on commit d9346ee

Please sign in to comment.