note 118270 deleted from function.array-pop by crell

From: Date: Tue, 12 Apr 2022 01:08:05 +0000
Subject: note 118270 deleted from function.array-pop by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218203@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- Let's "do stuff" with array_pop() <?php $dependecyInjection = ['globalState' => 'isHorrible']; $workQueue = array_reverse($workQueue); // O(n) // While we have stuff to do..... = [[ {function}, $params.... ], [], []...] while (!empty($workQueue)) { // O(1) : And resize array. (maybe also memory size ?) $work = array_pop($workQueue); // If not muted, invoke the worker function.... if (isset($work[0])) { $processor = array_shift($work); if ($moreWork = $processor->__invoke($work, $dependecyInjection)) { // <== Do stuff. // O(n) : add new stuff to the END of array ! (FIFO) $outputCommands += array_reverse($moreWork); } } }

« previous php.notes (#218203) next »