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


PHP SplDoublyLinkedList::isEmpty方法代码示例

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


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

示例1: isBinary

 /**
  * @return boolean
  */
 public function isBinary()
 {
     if ($this->_frames->isEmpty()) {
         throw new \UnderflowException('Not enough data has been received to determine if message is binary');
     }
     return Frame::OP_BINARY === $this->_frames->bottom()->getOpcode();
 }
开发者ID:RxPHP,项目名称:RxWebsocket,代码行数:10,代码来源:Message.php

示例2: retrieveMaintenanceTaskEntry

 /**
  * 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
 }
开发者ID:matthewstyler,项目名称:php-automobile-maintenence-tracker,代码行数:34,代码来源:MaintenanceTracker.php

示例3: traverse

 /**
  * Perform a depth-first traversal on the provided graph.
  *
  * @param Digraph $graph
  *   The graph on which to perform the depth-first search.
  * @param DepthFirstVisitorInterface $visitor
  *   The visitor object to use during the traversal.
  * @param object|\SplDoublyLinkedList $start
  *   A vertex, or vertices, to use as start points for the traversal. There
  *   are a few sub-behaviors here:
  *     - If an SplDoublyLinkedList, SplQueue, or SplStack is provided, the
  *       traversal will deque and visit vertices contained therein.
  *     - If a single vertex object is provided, it will be the sole
  *       originating point for the traversal.
  *     - If no value is provided, DepthFirst::find_sources() is called to
  *       search the graph for source vertices. These are place into an
  *       SplQueue in the order in which they are discovered, and traversal
  *       is then run over that queue in the same manner as if calling code
  *       had provided a queue directly. This method *guarantees* that all
  *       vertices in the graph will be visited.
  *
  * @throws RuntimeException
  *   Thrown if an invalid $start parameter is provided.
  */
 public static function traverse(Digraph $graph, DepthFirstVisitorInterface $visitor, $start = NULL)
 {
     if ($start === NULL) {
         $queue = self::find_sources($graph, $visitor);
     } else {
         if ($start instanceof \SplDoublyLinkedList) {
             $queue = $start;
         } else {
             if (is_object($start)) {
                 $queue = new \SplDoublyLinkedList();
                 $queue->push($start);
             }
         }
     }
     if ($queue->isEmpty()) {
         throw new RuntimeException('No start vertex or vertices were provided, and no source vertices could be found in the provided graph.', E_WARNING);
     }
     $visiting = new \SplObjectStorage();
     $visited = new \SplObjectStorage();
     $visitor->beginTraversal();
     $visit = function ($vertex) use($graph, $visitor, &$visit, $visiting, $visited) {
         if ($visiting->contains($vertex)) {
             $visitor->onBackEdge($vertex, $visit);
         } else {
             if (!$visited->contains($vertex)) {
                 $visiting->attach($vertex);
                 $visitor->onStartVertex($vertex, $visit);
                 foreach ($graph->successorsOf($vertex) as $head) {
                     $visitor->onExamineEdge($vertex, $head, $visit);
                     $visit($head);
                 }
                 $visitor->onFinishVertex($vertex, $visit);
                 $visiting->detach($vertex);
                 $visited->attach($vertex);
             }
         }
     };
     // TODO experiment with adding a generator-producing visitor method that yields the queue here
     while (!$queue->isEmpty()) {
         $vertex = $queue->shift();
         $visit($vertex);
     }
     $visitor->endTraversal();
 }
开发者ID:sdboyer,项目名称:gliph,代码行数:68,代码来源:DepthFirst.php

示例4: traverse

 /**
  * Perform a depth-first traversal on the provided graph.
  *
  * @param DirectedGraph $graph
  *   The graph on which to perform the depth-first search.
  * @param DepthFirstVisitorInterface $visitor
  *   The visitor object to use during the traversal.
  * @param object|\SplDoublyLinkedList $start
  *   A vertex, or vertices, to use as start points for the traversal. There
  *   are a few sub-behaviors here:
  *     - If an SplDoublyLinkedList, SplQueue, or SplStack is provided, the
  *       traversal will deque and visit vertices contained therein.
  *     - If a single vertex object is provided, it will be the sole
  *       originating point for the traversal.
  *     - If no value is provided, DepthFirst::find_sources() is called to
  *       search the graph for source vertices. These are place into an
  *       SplQueue in the order in which they are discovered, and traversal
  *       is then run over that queue in the same manner as if calling code
  *       had provided a queue directly. This method *guarantees* that all
  *       vertices in the graph will be visited.
  *
  * @throws RuntimeException
  *   Thrown if an invalid $start parameter is provided.
  */
 public static function traverse(DirectedGraph $graph, DepthFirstVisitorInterface $visitor, $start = NULL)
 {
     if ($start === NULL) {
         $queue = self::find_sources($graph, $visitor);
     } else {
         if ($start instanceof \SplDoublyLinkedList) {
             $queue = $start;
         } else {
             if (is_object($start)) {
                 $queue = new \SplDoublyLinkedList();
                 $queue->push($start);
             }
         }
     }
     if ($queue->isEmpty()) {
         throw new RuntimeException('No start vertex or vertices were provided, and no source vertices could be found in the provided graph.', E_WARNING);
     }
     $visiting = new \SplObjectStorage();
     $visited = new \SplObjectStorage();
     $visitor->beginTraversal();
     $visit = function ($vertex) use($graph, $visitor, &$visit, $visiting, $visited) {
         if ($visiting->contains($vertex)) {
             $visitor->onBackEdge($vertex, $visit);
         } else {
             if (!$visited->contains($vertex)) {
                 $visiting->attach($vertex);
                 $visitor->onStartVertex($vertex, $visit);
                 $graph->eachAdjacent($vertex, function ($to) use($vertex, &$visit, $visitor) {
                     $visitor->onExamineEdge($vertex, $to, $visit);
                     $visit($to);
                 });
                 $visitor->onFinishVertex($vertex, $visit);
                 $visiting->detach($vertex);
                 $visited->attach($vertex);
             }
         }
     };
     while (!$queue->isEmpty()) {
         $vertex = $queue->shift();
         $visit($vertex);
     }
     $visitor->endTraversal();
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:67,代码来源:DepthFirst.php

示例5:

$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)
// 删除参数索引的节点
$list->offsetUnset(3);
// add($index, $value);
// 对指定的索引新增一个新值。 当一个节点用offsetUnset时,并没有直接删除,该节点还仍然会保存在内存中。用add可以重新给该节点设置值
开发者ID:ray0916,项目名称:learn,代码行数:31,代码来源:splDoublyLinkedList.php

示例6: reverse

 /**
  * Make an iterable that will yield this iterable's values in reverse order. Keys in the
  * original iterable will be preserved.
  *
  * This iterable will be consumed in its entirety when `reverse()` is called.
  *
  * Examples
  *
  *   Crankshaft::Iter(['a', 'b', 'c', 'd', 'e'])->reverse()->to_array()
  *   // => [4 => 'e', 3 => 'd, 2 => 'c', 1 => 'b', 0 => 'a']
  *
  * Returns an Iterable.
  */
 public function reverse()
 {
     $keys = new \SplDoublyLinkedList();
     $values = new \SplDoublyLinkedList();
     foreach ($this as $key => $value) {
         $keys->push($key);
         $values->push($value);
     }
     $reversed = [];
     while (!$values->isEmpty()) {
         $reversed[$keys->pop()] = $values->pop();
     }
     return Crankshaft::Iter($reversed);
 }
开发者ID:thumbtack,项目名称:crankshaft,代码行数:27,代码来源:Iterable.php

示例7: SplDoublyLinkedList

<?php

// Create a new Doubly Linked List
$dll = new SplDoublyLinkedList();
var_dump($dll->isEmpty());
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:SplDoublyLinkedList_isEmpty_empty.php

示例8: SplDoublyLinkedList

<?php

// Create a new Doubly Linked List
$dll = new SplDoublyLinkedList();
// Add some items to the list
$dll->push(1);
$dll->push(2);
$dll->push(3);
//var_dump($dll);
var_dump($dll->isEmpty("test"));
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:SplDoublyLinkedList_isEmpty_not-empty-with-parameter.php

示例9: notify

 /**
  * Notify observers, this method will store the return value from each 
  * observer in a SplDoublyLinkedList. If any one of the observers returns
  * 'false', then the notification stops with the last value of the List
  * being 'false'.
  * 
  * @param string $event
  * @param mixed $args
  * @return SplDoublyLinkedList | return values from the observers
  */
 public function notify($event, $args = null)
 {
     $args = $args instanceof \stdClass && $args->name === 'static' ? $args->args : array_slice(func_get_args(), 1);
     $list = new SplDoublyLinkedList();
     foreach ($this->getObservers($event) as $observer) {
         $list->push($this->invoke($event, $observer, $args));
         if (!$list->isEmpty() && $list->top() === false) {
             break;
         }
     }
     return $list;
 }
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:22,代码来源:Dispatcher.php

示例10: isEmpty

 /**
  * Checks whether the list is empty or not.
  *
  * @return bool True if the list is empty, false otherwise.
  * @link http://www.php.net/manual/en/spldoublylinkedlist.isempty.php
  */
 public function isEmpty()
 {
     return $this->tokens->isEmpty();
 }
开发者ID:mohiva,项目名称:common,代码行数:10,代码来源:TokenStream.php


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