PHP Doku:: Constructs a new queue implemented using a doubly linked list - splqueue.construct.html

Verlauf / Chronik / History: (3) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige GrunderweiterungenStandard PHP Library (SPL)DatenstrukturenThe SplQueue classSplQueue::__construct

Ein Service von Reinhard Neidl - Webprogrammierung.

The SplQueue class

<<The SplQueue class

SplQueue::dequeue>>

SplQueue::__construct

(PHP 5 >= 5.3.0)

SplQueue::__constructConstructs a new queue implemented using a doubly linked list

Beschreibung

SplQueue::__construct() ( void )

This constructs a new empty queue.

Hinweis:

This method automatically sets the iterator mode to SplDoublyLinkedList::IT_MODE_FIFO.

Parameter-Liste

Diese Funktion hat keine Parameter.

Rückgabewerte

Es wird kein Wert zurückgegeben.

Beispiele

Beispiel #1 SplQueue::__construct() example

<?php
$q 
= new SplQueue();

$q[] = 1;
$q[] = 2;
$q[] = 3;

foreach (
$q as $elem)  {
 echo 
$elem."\n";
}
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

1
2
3

Beispiel #2 Efficiently handling tasks with SplQueue

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

// ... enqueue some tasks on the queue ...

// process them
foreach ($q as $task) {
    
// ... process $task ...

    // add new tasks on the queue
    
$q[] = $newTask;
    
// ...
}
?>


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)