当前位置: 首页>>代码示例>>PHP>>正文


PHP Queue::isEmpty方法代码示例

本文整理汇总了PHP中Queue::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP Queue::isEmpty方法的具体用法?PHP Queue::isEmpty怎么用?PHP Queue::isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Queue的用法示例。


在下文中一共展示了Queue::isEmpty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: resume

 public static function resume($coroutine)
 {
     $wrapCurrent = true;
     $coKey = $coroutine->key();
     if ($coKey && in_array($coKey, self::$_ioQueue)) {
         //io中断,执行队列不为空则将当前协程入栈
         if (!Queue::isEmpty($coKey)) {
             Queue::push($coKey, $coroutine);
             $wrapCurrent = false;
         }
     }
     if ($wrapCurrent) {
         //是否立即执行当前协程
         self::wrap($coroutine);
     }
 }
开发者ID:jmuyuyang,项目名称:co-psf,代码行数:16,代码来源:Coroutine.php

示例2: isEmpty

    }
    public function isEmpty()
    {
        if ($this->front === null) {
            return true;
        } else {
            return false;
        }
    }
    public function isFull()
    {
    }
}
$q = new Queue(5);
// instantiates the Queue class with a maxSize attribute of 5
$q->isEmpty();
// returns true
$q->enqueue(100);
// Queue: 100
$q->rear();
// returns 100
$q->front();
// returns 100
$q->enqueue(20);
// Queue: 100, 20
$q->enqueue(2);
// Queue: 100, 20, 2
$q->dequeue();
// Queue: 20, 2
$q->enqueue(500);
// Queue: 20, 2, 500
开发者ID:sourabhpal,项目名称:PHP,代码行数:31,代码来源:index.php

示例3: formCluster

 /**
  * Forms the clusters by removing maximum weighted edges.
  * performs breadth-first search to cluster the recipes.
  *
  * @param int $k queue size
  * @param int $size number of recipes.
  * @return array $cluster clusters of recipes.
  */
 function formCluster($k, $size)
 {
     $this->cluster_heap->top();
     $nodeQueue = new Queue($k);
     $cluster_count = $size * CLUSTER_RATIO;
     $cluster = array();
     /*
        Idea remove $cluster_count many weightiest edges from tree
        to get a forest. As do this add to queue end points of
        removed edges.
     */
     for ($j = 0; $j < $cluster_count - 1; $j++) {
         $max_edge = $this->cluster_heap->extract();
         $cluster1_start = $max_edge->getStartVertex()->getLabel();
         $cluster2_start = $max_edge->getEndVertex()->getLabel();
         $this->adjMatrix[$cluster1_start][$cluster2_start] = -1;
         $this->adjMatrix[$cluster2_start][$cluster1_start] = -1;
         $nodeQueue->enqueue($cluster1_start);
         $nodeQueue->enqueue($cluster2_start);
     }
     $queue = new Queue($k);
     $i = 0;
     // Now use Queue above to make clusters (trees in resulting forest)
     while (!$nodeQueue->isEmpty()) {
         $node = $nodeQueue->dequeue();
         if ($this->vertices[$node]->isVisited() == false) {
             $this->vertices[$node]->visited();
             $cluster[$i][] = $this->vertices[$node]->getLabel();
             $queue->enqueue($this->vertices[$node]->getLabel());
             while (!$queue->isEmpty()) {
                 $node = $queue->dequeue();
                 while (($nextnode = $this->getNextVertex($node)) != -1) {
                     $this->vertices[$nextnode]->visited();
                     $cluster[$i][] = $this->vertices[$nextnode]->getLabel();
                     $queue->enqueue($this->vertices[$nextnode]->getLabel());
                 }
             }
         }
         $i++;
     }
     return $cluster;
 }
开发者ID:yakar,项目名称:yioop,代码行数:50,代码来源:recipe_plugin.php

示例4: print

        }
    }
    public function print()
    {
        echo "Queue: ";
        $current = $this->front;
        while ($current) {
            echo $current->value . ", ";
            $current = $current->next;
        }
        echo "<br>";
    }
}
$q = new Queue(5);
// instantiates the Queue class with a maxSize attribute of 5
echo $q->isEmpty() . "<br>";
// returns true
$q->enqueue(100);
// Queue: 100
echo $q->rear() . "<br>";
// returns 100
echo $q->front() . "<br>";
// returns 100
$q->enqueue(20);
// Queue: 100, 20
$q->enqueue(2);
// Queue: 100, 20, 2
$q->dequeue();
// Queue: 20, 2
$q->enqueue(500);
// Queue: 20, 2, 500
开发者ID:nicksc423,项目名称:Algorithms,代码行数:31,代码来源:queue.php


注:本文中的Queue::isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。