xref: /PHP-8.2/ext/spl/tests/dllist_003.phpt (revision a555cc0b)
1--TEST--
2SPL: DoublyLinkedList: iterator modes
3--FILE--
4<?php
5$dll = new SplDoublyLinkedList();
6$dll->push(2);
7$dll->push(3);
8$dll->push(4);
9
10$dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
11
12foreach ($dll as $k => $v) {
13    echo "$k=>$v\n";
14}
15
16$dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
17foreach ($dll as $k => $v) {
18    echo "$k=>$v\n";
19}
20
21$dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_DELETE);
22var_dump($dll->count());
23foreach ($dll as $k => $v) {
24    echo "$k=>$v\n";
25}
26var_dump($dll->count());
27
28?>
29--EXPECT--
302=>4
311=>3
320=>2
330=>2
341=>3
352=>4
36int(3)
370=>2
380=>3
390=>4
40int(0)
41