예제 #1
0
 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
 }
예제 #3
0
파일: Router.php 프로젝트: zorca/parvula
 /**
  * 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);
             }
         }
     }
 }
예제 #4
0
 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() . " ";
     }
 }
예제 #5
0
$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);
// offsetSet($index, $newValue)
// 设置参数索引的节点值, $index必须在链表的键范围中。
// 当一个节点用offsetUnset删掉时时,并不能用offsetSet重新给已删掉的节点设置值,只能对当前可见的节点的值进行修改
$list->offsetSet(3, 'value6');
// offsetUnset($index)
// 删除参数索引的节点
예제 #6
0
                                <?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===
예제 #8
0
$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)
  * Checks if current position is valid
  *
  * @link http://php.net/manual/en/iterator.valid.php
  * @return boolean The return value will be casted to boolean and then evaluated.
  */
 public function valid()
 {
     return $this->storage->valid();
 }
예제 #10
0
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";
예제 #11
0
<?php

$list = new SplDoublyLinkedList();
$list->push('a');
$list->add(1, 'e');
$list->push('b');
$list->push('c');
$list->push('d');
$list->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
$list->rewind();
while ($list->valid()) {
    echo $list->current(), "\n";
    $list->next();
}
예제 #12
0
 $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) {
예제 #13
0
 /**
  * Check whether the list contains more tokens.
  *
  * @return bool True if the list contains any more tokens, false otherwise.
  * @link http://www.php.net/manual/en/spldoublylinkedlist.valid.php
  */
 public function valid()
 {
     return $this->tokens->valid();
 }