Beispiel #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();
     }
 }
Beispiel #2
0
$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);
// offsetSet($index, $newValue)
// 设置参数索引的节点值, $index必须在链表的键范围中。
// 当一个节点用offsetUnset删掉时时,并不能用offsetSet重新给已删掉的节点设置值,只能对当前可见的节点的值进行修改
Beispiel #3
0
<?php

$dll = new SplDoublyLinkedList();
$dll->push(1);
$dll->push(2);
$dll->push(3);
$dll->push(4);
$dll->rewind();
$dll->prev();
var_dump($dll->current());
$dll->rewind();
var_dump($dll->current());
$dll->next();
var_dump($dll->current());
$dll->next();
$dll->next();
var_dump($dll->current());
$dll->prev();
var_dump($dll->current());
?>
===DONE===
Beispiel #4
0
 /**
  * Move to previous token.
  *
  * @link http://www.php.net/manual/en/spldoublylinkedlist.prev.php
  */
 public function prev()
 {
     $this->tokens->prev();
 }