PHP.mk документација

SplQueue::dequeue

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

splqueue.dequeue.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека splqueue.dequeue.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
SplQueue::dequeue

Референца за `splqueue.dequeue.php` со подобрена типографија и навигација.

splqueue.dequeue.php

SplQueue::dequeue

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

SplQueue::dequeueDequeues a node from the queue

= NULL

public SplQueue::dequeue(): mixed

Dequeues value from the top of the queue.

Забелешка:

SplQueue::dequeue() е псевдоним за SplDoublyLinkedList::shift().

Параметри

Оваа функција нема параметри.

Вратени вредности

The value of the dequeued node.

Белешки од корисници 4 белешки

xuecan at gmail dot com
пред 16 години
If the queue is empty, dequeue() will raise an 'RuntimeException' with message 'Can't shift from an empty datastructure'.
mark at bull-roarer dot com
12 години пред
I just thought this was a fun and interesting way for lining up method calls and then calling them back-to-back. Might be useful as a basis for a transactional execution class or something.

<?php
$q = new SplQueue();
$q->setIteratorMode(SplQueue::IT_MODE_DELETE);

$q->enqueue(array("FooBar", "foo"));
$q->enqueue(array("FooBar", "bar"));
$q->enqueue(array("FooBar", "msg", "Hi there!"));

foreach ($q as $task) {
  if (count($task) > 2) {
    list($class, $method, $args) = $task;
    $class::$method($args);
  } else {
    list($class, $method) = $task;
    $class::$method();
  }
}

class FooBar {
  public static function foo() { 
    echo "FooBar::foo() called.\n";
  }
  public static function bar() {
    echo "FooBar::bar() called.\n";
  }
  public static function msg($msg) {
    echo "$msg\n";
  }
}
?>

Results:
FooBar::foo() called.
FooBar::bar() called.
Hi there!
andresdzphp at php dot net
пред 14 години
<?php
$q = new SplQueue();
$q->setIteratorMode(SplQueue::IT_MODE_DELETE);
$q->enqueue('item 1');
$q->enqueue('item 2');
$q->enqueue('item 3');

$q->dequeue();
$q->dequeue();

foreach ($q as $item) {
    echo $item;
}

//Result: item 3

$q->dequeue(); //Fatal error: Uncaught exception 'RuntimeException' 
              //with message 'Can't shift from an empty datastructure'
?>
mark at bull-roarer dot com
12 години пред
I just thought this was a fun and interesting way for lining up method calls and then calling them back-to-back. Might be useful as a basis for a transactional execution class or something.

<?php
$q = new SplQueue();
$q->setIteratorMode(SplQueue::IT_MODE_DELETE);

$q->enqueue(array("FooBar", "foo"));
$q->enqueue(array("FooBar", "bar"));
$q->enqueue(array("FooBar", "msg", "Hi there!"));

foreach ($q as $task) {
  if (count($task) > 2) {
    list($class, $method, $args) = $task;
    $class::$method($args);
  } else {
    list($class, $method) = $task;
    $class::$method();
  }
}

class FooBar {
  public static function foo() { 
    echo "FooBar::foo() called.\n";
  }
  public static function bar() {
    echo "FooBar::bar() called.\n";
  }
  public static function msg($msg) {
    echo "$msg\n";
  }
}
?>

Results:
FooBar::foo() called.
FooBar::bar() called.
Hi there!
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.