(Available since version 1.0)
The LinkedList class provides the main functionalities of a singly linked list.
It provides the interface as SplDoublyLinkedList but doesn't support LIFO mode. It can therefore be used as a drop-in replacement for SplDoublyLinkedList when you do not need LIFO.
On top of SplDoublyLinkedList's interface this class provides the following extra methods:
Please note that in practice many operations are more computationally expensive on singly linked lists relative to doubly linked lists. Additionally, this class is implemented in PHP whereas SplDoublyLinkedList is implemented in C, which is considerably faster.
This class is therefore not recommended for production code, and is provided for the sake of completeness and experimental purposes.
LinkedList::IT_MODE_DELETE
(1) Flag for deleting whilst iterating.
LinkedList::IT_MODE_KEEP
(0) Absence of flag for deleting whilst iterating.
LinkedList::IT_MODE_LIFO
(2) Flag for Last In First Out mode.
LinkedList::IT_MODE_FIFO
(0) Absence of flag for Last In First Out mode.
The first item in the list.
The last item in the list.
The current item (when iterating).
The index of the current item.
The last item the class 'worked' on.
The index of the last item the class 'worked' on.
The number of items in the list.
The iteration mode.