What is the point of PHP's SplDoublyLinkedList class, and more importantly, Linked Lists in general?

Viewed 6669

On a quest to expand my programming prowess, I've delved ever-so-slightly into The Standard PHP Library. This led to my discovery of the SplDoublyLinkedList class. From there I read the descriptions of Linked Lists and Doubly Linked Lists on Wikipedia.

I understand how they work... But I cannot conceive of a reason WHY we need it—or better yet a practical example of SplDoublyLinkedList since we have indexed and associative arrays in PHP.

How are Linked Lists normally used in-and-out of PHP?

7 Answers

Perhaps you are writing a web application in order to make a website look and act like a book (like epub online). A collapsible TOC (table of contents) would provide random access. The linked list would provide a convenient way to implement "next page" and "previous page" buttons. Next and Previous could be implemented in other ways. The linked list would make it a snap.

Related