Annotation of embedaddon/php/ext/spl/internal/splstack.inc, revision 1.1.1.1
1.1 misho 1: <?php
2:
3: /** @file splstack.inc
4: * @ingroup SPL
5: * @brief class SplStack
6: * @author Etienne Kneuss
7: * @date 2008 - 2009
8: *
9: * SPL - Standard PHP Library
10: */
11:
12: /** @ingroup SPL
13: * @brief Implementation of a stack through a DoublyLinkedList. As SplStack
14: * extends SplDoublyLinkedList, shift() and unshift() are still available even
15: * though they don't make much sense for a stack.
16: * @since PHP 5.3
17: *
18: * The SplStack class provides the main functionalities of a
19: * stack implemented using a doubly linked list (DLL).
20: */
21: class SplStack extends SplDoublyLinkedList
22: {
23: protected $_it_mode = parent::IT_MODE_LIFO;
24:
25: /** Changes the iteration mode. There are two orthogonal sets of modes that
26: * can be set:
27: *
28: * - The behavior of the iterator (either one or the other)
29: * - SplDoublyLnkedList::IT_MODE_DELETE (Elements are deleted by the iterator)
30: * - SplDoublyLnkedList::IT_MODE_KEEP (Elements are traversed by the iterator)
31: *
32: * The default mode is 0 : SplDoublyLnkedList::IT_MODE_LIFO | SplDoublyLnkedList::IT_MODE_KEEP
33: *
34: * @note The iteration's direction is not modifiable for stack instances
35: * @param $mode New mode of iteration
36: * @throw RuntimeException If the new mode affects the iteration's direction.
37: */
38: public function setIteratorMode($mode)
39: {
40: if ($mode & parent::IT_MODE_LIFO !== parent::IT_MODE_LIFO) {
41: throw new RuntimeException("Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen");
42: }
43:
44: $this->_it_mode = $mode;
45: }
46: }
47:
48: ?>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>