private function nextTick() { $this->future->rewind(); while ($this->future->valid() && ($task = $this->future->current())) { if (!$task->isBlocked() || !$task->isStarted()) { $this->tick->enqueue($task); $this->future->offsetUnset($this->future->key()); $this->future->prev(); } $this->future->next(); } }
/** * Retrieve the maintenance task entry, from unique identfier * @param $maintenanceTaskEntryIdentifier Identifier to locate entry * @return mixed|null Returns the maintenance task entry or null on error * @throws InvalidArgumentException if the provided argument is not set or of correct type */ public function retrieveMaintenanceTaskEntry($maintenanceTaskEntryIdentifier) { if (!isset($maintenanceTaskEntryIdentifier)) { //argument check throw new InvalidArgumentException("Missing Argument"); } else { if (!is_numeric($maintenanceTaskEntryIdentifier)) { //argument check throw new InvalidArgumentException("maintenanceTaskEntryIdentifier is not a number"); } } if ($this->maintenanceTaskList->isEmpty()) { //if list is empty, unable to return entry return null; } else { $this->maintenanceTaskList->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO); //set iteration FIFO for ($this->maintenanceTaskList->rewind(); $this->maintenanceTaskList->valid(); $this->maintenanceTaskList->next()) { if ($this->maintenanceTaskList->current()->getTaskEntryIdentifier() == $maintenanceTaskEntryIdentifier) { //if entry identifier matches supplied identifier return $this->maintenanceTaskList->current(); } //return the matching entry } } return null; //entry with given identifier not found }
/** * Dispatch * @return mixed */ private function dispatch() { // for each route for (; $this->routes->valid(); $this->routes->next()) { $route = $this->routes->current(); // if method is OK if (strtoupper($route['method']) === $this->method || $route['method'] === '*') { $regex = $this->normalizeRegex($route['path']); // if path is OK if (preg_match("@^{$regex}@", $this->uri, $matches)) { $callback = $route['callback']; $req = new \ArrayObject(); $req->params = (object) $matches; $req->uri = $this->uri; $req->path = $this->path; $req->query = $this->query; if ($this->method !== 'GET') { if (!isset($data)) { parse_str(file_get_contents("php://input"), $data); } $req->body = $data; } $that = $this; $next = function () use($that) { $that->routes->next(); $that->dispatch(); }; return $callback($req, $next); } } } }
public function __construct() { $listLink = new SplDoublyLinkedList(); $listLink->push('Albin'); $listLink->push('to'); $listLink->push('the'); $listLink->push('interface;'); $listLink->push('not'); $listLink->push('the'); $listLink->push('Sandi'); echo "<strong>Free good advice :</strong><br />"; $listLink->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO); for ($listLink->rewind(); $listLink->valid(); $listLink->next()) { echo $listLink->current() . " "; } echo "<br /><br /><strong>Yoda talk: last in first out:</strong><br />"; $listLink->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO); for ($listLink->rewind(); $listLink->valid(); $listLink->next()) { echo $listLink->current() . " "; } }
$list->count(); // rewind() // 将指针返回至初始节点 $list->rewind(); // current() // 获得当前节点 $list->current(); // top() // 返回最后一个节点的值 $list->top(); // bottom() // 返回第一个节点的值 $list->bottom(); // next() // 指针移到下一个节点 $list->next(); // prev() // 指针移到上一个节点, 如果原本指针在第一个,那么前一个节点为-1,并且将无法获得当前值 $list->prev(); // valid() // 判断该链表是否有更多的值,返回bool $list->valid(); // isEmpty() // 判断该链表是否为空链表,返回bool $list->isEmpty(); // offsetExists($index) // 判断参索引是否存在,返回bool $list->offsetExists(2); // offsetGet($index) // 返回参数索引的节点值 $list->offsetGet(2);
<?php $list = new SplDoublyLinkedList(); $list->push('o'); $list->push('o'); $list->push('f'); $list->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO); $list->rewind(); while ($tmp = $list->current()) { echo $tmp; $list->next(); }
<?php $listPasilloSession = unserialize($_SESSION['listPasillo']); $listPasilloTP = $listPasilloSession->offsetGet($_GET['pas']); $listPa = $listPasilloTP->getTypeProducts(); $listProducts2 = $listPa->offsetGet($_GET['type']); $listProducts3 = $listProducts2->getListProduct(); $listProductsTP2 = $listProducts3->offsetGet($_GET['prods']); $listProducts = $listProductsTP2->getListProducts(); $listPila = new SplDoublyLinkedList(); $listProducts->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO); for ($listProducts->rewind(); $listProducts->valid(); $listProducts->next()) { $data = $listProducts->current(); $listPila->push($data); } $listPila->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO); for ($listPila->rewind(); $listPila->valid(); $listPila->next()) { $dataPila = $listPila->current(); ?> <tr> <td class="center"><?php echo $dataPila->getIdProduct(); ?> </td> <td><?php echo $dataPila->getProduct(); ?> </td> <td class="center"> <?php if ($_SESSION['admin'] == 1) { ?>
<?php $a = new SplDoublyLinkedList(); $a->push(1); $a->push(2); $a->push(3); $a->rewind(); while ($a->valid()) { var_dump($a->current(), $a->next()); } ?> ===DONE===
$dlanguages->push(['Languages', 'Uses', 'Ranking']); $dlanguages->push(['C++', 'computing', 99.59999999999999]); $dlanguages->push(['C', 'computing', 99.90000000000001]); $dlanguages->push(['Java', 'application', 100]); $dlanguages->push(['C#', 'application', 91.8]); $dlanguages->push(['Python', 'application', 95.8]); $dlanguages->push(['PHP', 'web', 84.5]); $dlanguages->push(['Perl', 'web', 66.90000000000001]); $dlanguages->push(['R', 'computing', 84.7]); $dlanguages->push(['Ruby', 'web', 75.3]); $dlanguages->push(['VB.NET', 'application', 63.4]); $dlanguages->push(['Javascript', 'web', 83]); $dlanguages->push(['Matlab', 'computing', 72.40000000000001]); echo "\nDOUBLY LINK LIST LOOP: FIFO\n"; $dlanguages->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO); for ($dlanguages->rewind(); $dlanguages->valid(); $dlanguages->next()) { echo $dlanguages->current()[0] . "\n"; echo $dlanguages->current()[1] . "\n"; echo $dlanguages->current()[2] . "\n"; } /* FIXED ARRAY */ $fdatabases = new SplFixedArray(11); $fdatabases[0] = ['Databases', 'Type', 'Size', 'Ranking']; $fdatabases[1] = ['Oracle', 'Proprietary', 'Server', 1497.55]; $fdatabases[2] = ['SQL Server', 'Proprietary', 'Server', 1123.16]; $fdatabases[3] = ['PostgreSQL', 'Open-Source', 'Server', 280.09]; $fdatabases[4] = ['MySQL', 'Open-Source', 'Server', 1298.54]; $fdatabases[5] = ['DB2', 'Proprietary', 'Server', 196.13]; $fdatabases[6] = ['SQLite', 'Open-Source', 'File', 100.85]; $fdatabases[7] = ['MS Access', 'Proprietary', 'File', 140.21]; $fdatabases[8] = ['SAP Sybase', 'Proprietary', 'Server', 81.47];
/** * (PHP 5 >= 5.1.0) * Move forward to next element * * @link http://php.net/manual/en/iterator.next.php * @return void Any returned value is ignored. */ public function next() { $this->storage->next(); }
print "<a style = \"float:right\" href=\"logout.php\">Logout </a><br>"; print "<a href = \"javascript: changeAvatar('userExtenPanel');\"><img id = \"userAvatar\" class = \"userAvatar\" src = \"/picsUploads/" . $avatar . "\"></a><br>"; print "<a href = \"javascript: changeAvatar('userExtenPanel');\"> Choose Avatar</a><br>"; print "</div>"; print "<div id = \"userTrvHistPanel\" class = \"userTrvHistPanel\">"; if (isset($_SESSION['loginId']) && $_SESSION['loginId'] !== "admin") { print "Travel History\t\t<a href = \"javascript: updateUserInfo('clearHist');\">Clear</a>"; if (isset($travelHistList)) { //prints the labels for the travel history table print "<table border='0px'>"; print "<tr>"; print "<td style= 'color:#CC0000; font-weight:bold'>Departing Airport\t\t\t\t\t\t\t</td>"; print "<td style= 'color:#CC0000; font-weight:bold'>Arrival Airport\t\t\t\t\t\t\t\t</td>"; print "<td style= 'color:#CC0000; font-weight:bold'>Date Traveled \t</td>"; print "<td style= 'color:#CC0000; font-weight:bold'>Leased Model\t\t\t\t\t\t\t</td>"; print "</tr>"; for ($travelHistList->rewind(); $travelHistList->valid(); $travelHistList->next()) { print "<tr><td>" . $travelHistList->current()->depart . "</td><td>" . $travelHistList->current()->arrive . "</td><td>" . $travelHistList->current()->travelDate . "</td><td>" . $travelHistList->current()->leasedModel . "</td></tr>"; } print "</table></font>"; } else { print "Error loading travel history table"; } } print "</div>"; print "</div>"; print "</font>"; print "</div>"; print "<script>saveTrvHist();</script>"; print "<label id = \"xmlRespondFeedback\" style = \"visibility:hidden;\"></label>"; include "tailHTML.html";
<?php $dll = new SplDoublyLinkedList(); $dll->push(1); $dll->push(2); $dll->push(3); $dll->push(4); $dll->rewind(); echo $dll->current() . "\n"; $dll->next(); $dll->next(); echo $dll->current() . "\n"; ?> ===DONE===
$planeWaitList = unserialize($row['planeWaitList']); $airport = $row['airport']; if ($planeWaitList != NULL) { for ($planeWaitList->rewind(); $planeWaitList->valid(); $planeWaitList->next()) { $memberWaitList = $planeWaitList->current(); $plane = $memberWaitList->offsetGet(0); //we're only interested in the first element of the list, since the first element of the memberWaitList is the model of the plane for ($memberWaitList->rewind(); $memberWaitList->valid(); $memberWaitList->next()) { $member = $memberWaitList->current(); $positionInLine = $memberWaitList->key(); if ($member == $_SESSION['loginId']) { preg_match('/^[^,]*/', $airport, $matches); // put the * back before the / if ($matches) { $elemExist = 0; for ($tempBfr->rewind(); $tempBfr->valid(); $tempBfr->next()) { if ($tempBfr->current() == "<tr><td>" . $positionInLine . "</td><td>" . $plane . "</td><td>" . $matches[0] . "</td></tr>") { $elemExist = 1; } } if (!$elemExist) { $tempBfr->push("<tr><td>" . $positionInLine . "</td><td>" . $plane . "</td><td>" . $matches[0] . "</td></tr>"); } } else { $elemExist = 0; for ($tempBfr->rewind(); $tempBfr->valid(); $tempBfr->next()) { if ($tempBfr->current() == "<tr><td>" . $positionInLine . "</td><td>" . $plane . "</td><td>" . $airport . "</td></tr>") { $elemExist = 1; } } if (!$elemExist) {
/** * Move to next token. * * @link http://www.php.net/manual/en/spldoublylinkedlist.next.php */ public function next() { $this->tokens->next(); }