The PHP Standard PHP Library (SPL) has an implementation of a doubly linked list, which is known as SplDoublyLinkedList. If we are using the built-in class, we do not need to implement the doubly linked list ourselves. The doubly linked list implementation actually works as a stack and queue as well. The PHP implementation of the doubly linked list has lots of additional functionalities. Here are some of the common features of SplDoublyLinkedList:
Method |
Description |
Add |
Adds a new node in a specified index |
Bottom |
Peeks a node from beginning of the list |
Count |
Returns the size of the list |
Current |
Returns the current node |
getIteratorMode |
Returns the mode of iteration |
setIteratorMode |
Sets the mode of iteration. For example, LIFO, FIFO, and so on |
Key |
Returns the current node index |
next |
Moves to the... |