From the course: Learning the Standard PHP Library
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Doubly linked lists, stacks, and queues - PHP Tutorial
From the course: Learning the Standard PHP Library
Doubly linked lists, stacks, and queues
Although iterators were the initial focus of the standard PHP library, several useful data structures were added in PHP 5.3, including doubly linked lists, stacks, and queues. A linked list is similar to a PHP array, but it differs in that each element knows about its neighbor. In a singly linked list, each time an element is added, it creates a link to the one preceding it. In a doubly linked list which is what SPL has implemented, the links go both ways. So each element has a link to the preceding and following elements. To start a list, create an instance of the SplDoublyLinkedList class. You can add elements to the list using bracket notation in exactly the same way as an array. Alternatively, use the object push method, passing the value as an argument to the method. Keep building the list by adding new elements on the end, using either push or bracket notation. The first element is referred to as the bottom of the list. The most recent element is known as the top. You can get…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Doubly linked lists, stacks, and queues3m 10s
-
(Locked)
Sorting XML and JSON with SplDoublyLinkedList8m 26s
-
(Locked)
Using SplStack and SplQueue6m 25s
-
(Locked)
Understanding heaps2m 55s
-
(Locked)
SplMinHeap and SplMaxHeap5m 3s
-
(Locked)
Sorting XML and JSON with SplHeap7m 9s
-
(Locked)
Finding important information with SplPriorityQueue5m 32s
-
(Locked)
Keeping priority items in chronological order4m 23s
-
(Locked)
Speeding up array access with SplFixedArray6m 48s
-
(Locked)
-