本文整理汇总了PHP中SplQueue::valid方法的典型用法代码示例。如果您正苦于以下问题:PHP SplQueue::valid方法的具体用法?PHP SplQueue::valid怎么用?PHP SplQueue::valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplQueue
的用法示例。
在下文中一共展示了SplQueue::valid方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: route
/**
* Runs through all the routes and runs them
* @author Tim Perry
*/
public function route()
{
$this->routes->rewind();
while ($this->routes->valid()) {
$route = $this->routes->current();
if ($route->run()) {
return;
}
$this->routes->next();
}
throw new \RuntimeException("FlexPress router: No route found - please make sure you have setup routes.");
}
示例2: run
/**
* Runs through all the callable functions provided, if all are met call the given callable
* @author Tim Perry
*/
public function run()
{
if (!isset($this->conditions) || !isset($this->callable)) {
$message = "You have called the run function but have not provided both a array of conditions";
$message .= " and a callable function, which will be called if all the given conditions are met.";
throw new \RuntimeException($message);
}
$this->conditions->rewind();
while ($this->conditions->valid()) {
$condition = $this->conditions->current();
if (!call_user_func($condition)) {
return false;
}
$this->conditions->next();
}
call_user_func($this->callable, $this->request);
return true;
}
示例3: call
/**
* 调用 middleware
*
* @return mixed
*/
public function call()
{
$this->queue->rewind();
while ($this->queue->valid()) {
if ($this->getPropagation()) {
break;
}
$callbale = $this->queue->current();
$response = call_user_func_array($callbale, func_get_args());
if ($response === false) {
break;
} elseif (!empty($response)) {
$this->response = $response;
}
$this->queue->next();
}
return $this->response;
}
示例4: StringifyBreadcrumbs
/**
* Return breadcrumb string
**/
function StringifyBreadcrumbs()
{
$output = "<ul class=\"breadcrumb\" id=\"breadcrumb\">";
if (0 != $this->GetConfigValue('enable_breadcrumbs') && isset($_SESSION['user']) && isset($_SESSION['breadcrumbs'])) {
$delimiter = $this->GetConfigValue('breadcrumb_node_delimiter');
$q = new SplQueue();
$q->unserialize($_SESSION['breadcrumbs']);
$q->rewind();
$output .= "<li>";
$output .= "<a href=\"" . $this->Href('', $q->current()) . "\">" . $q->current() . "</a>";
$q->next();
while ($q->valid()) {
$output .= " {$delimiter} ";
$output .= "</li><li>";
$output .= "<a href=\"" . $this->Href('', $q->current()) . "\">" . $q->current() . "</a>";
$q->next();
}
$output .= "</li></ul>";
}
return $output;
}
示例5: serveronly
$qoperatingsystems = new SplQueue();
$qoperatingsystems->push(array('Windows 7', 'desktop', 'NT', 56.11));
$qoperatingsystems->push(array('Windows XP', 'desktop', 'NT', 10.59));
$qoperatingsystems->push(array('Windows 8', 'desktop', 'NT', 2.88));
$qoperatingsystems->push(array('Windows 8.1', 'desktop', 'NT', 11.15));
$qoperatingsystems->push(array('Windows 10', 'desktop', 'NT', 9));
$qoperatingsystems->push(array('Windows Vista', 'desktop', 'NT', 0));
$qoperatingsystems->push(array('Mac OS X 11', 'desktop', 'Unix', 2.66));
$qoperatingsystems->push(array('Mac OS X 10', 'desktop', 'Unix', 2.45));
$qoperatingsystems->push(array('Linux Mint', 'desktop', 'Linux', 0));
$qoperatingsystems->push(array('Linux Debian', 'desktop', 'Linux', 0));
$qoperatingsystems->push(array('Android', 'mobile', 'Linux', 48.12));
$qoperatingsystems->push(array('iOS', 'mobile', 'Unix', 34.71));
echo "\nSPL QUEUE ARRAY FOR LOOP: FIFO\n";
$qoperatingsystems->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
for ($qoperatingsystems->rewind(); $qoperatingsystems->valid(); $qoperatingsystems->next()) {
echo $qoperatingsystems->current()[0] . "\n";
echo $qoperatingsystems->current()[1] . "\n";
echo $qoperatingsystems->current()[2] . "\n";
echo $qoperatingsystems->current()[3] . "\n";
}
/* ------------------BASIC OPERATIONS------------------ */
// SORT
// BY LANGUAGE RANKING
usort($nlanguages, function ($a, $b) {
return $b[2] - $a[2];
});
// FILTER
// BY DATABASE SIZE
function serveronly($var)
{
示例6: bufferValid
/**
* Determines if we have a valid buffer for optimising.
*
* Has to be G1s all round with no Z movements, and either all extrusions or all movements.
*
* The extrusions also have to be the same mm^3/mm along the path.
*
* They also have to describe a circle
* @param SplQueue $buffer The buffer
* @return Boolean Whether the buffer is valid
*/
function bufferValid($buffer)
{
global $debug;
global $pos_error;
for ($buffer->rewind(); $buffer->valid(); $buffer->next()) {
if (substr($buffer->current(), 0, 2) !== "G1") {
$buffer->rewind();
return false;
} else {
if (strpos($buffer->current(), "Z") !== FALSE) {
$buffer->rewind();
return false;
}
}
}
$lines = getLines($buffer);
$allE = false;
$allF = false;
if (!is_null($lines[0]['E'])) {
$allE = true;
}
if (!is_null($lines[0]['F'])) {
$allF = true;
}
foreach ($lines as $num => $line) {
$allE = $allE && is_null($line['F']) && !is_null($line['E']);
$allF = $allF && is_null($line['E']) && !is_null($line['F']);
}
if (!($allE || $allF)) {
$buffer->rewind();
return false;
}
if ($allE) {
$extrusions = getExtrusionLengths($lines);
$eerror = calculateExtrusionError($extrusions);
if (calculateExtrusionError($extrusions) === false) {
$buffer->rewind();
return false;
}
}
$lines->rewind();
$circle = getCircle($lines);
if ($circle === false) {
$buffer->rewind();
return false;
}
if (max($circle['errors']) > $pos_error) {
return false;
}
$buffer->rewind();
return $circle;
}
示例7: valid
/**
* 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->queue->valid();
}