What are the SPL data structures

PHP: What are the SPL data structures

The SPL (Standard PHP Library) includes several data structures that you should be aware of and hopefully use. Here is an overview of them:

SplDoublyLinkedList — The SplDoublyLinkedList class - this provides the main functionalities of a doubly linked list

SplStack — The SplStack class - this provides the main functionalities of a stack implemented using a doubly linked list.

SplQueue — The SplQueue class - this provides the main functionalities of a queue implemented using a doubly linked list.

SplHeap — The SplHeap class - this provides the main functionalities of a Heap.

SplMaxHeap — The SplMaxHeap class - this provides the main functionalities of a heap, keeping the maximum on the top.

SplMinHeap — The SplMinHeap class - this provides the main functionalities of a heap, keeping the minimum on the top.

SplPriorityQueue — The SplPriorityQueue class - this provides the main functionalities of a prioritized queue, implemented using a max heap.

SplFixedArray — The SplFixedArray class - this provides the main functionalities of array. The main differences between a SplFixedArray and a normal PHP array is that the SplFixedArray is of fixed length and allows only integers within the range as indexes. The advantage is that it allows a faster array implementation.

SplObjectStorage — The SplObjectStorage class - this provides a map from objects to data or, by ignoring data, an object set. This dual purpose can be useful in many cases involving the need to uniquely identify objects.

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about What are the SPL data structures

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the PHP language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to sort an array of dates and times?

How to set custom HTTP headers in Apache (by editing .htaccess)

301 Redirect a single URL in .htaccess to a new location

What are Template literals (Template strings) in JS?

How to add a name prefix to all routes in a group?

How to eager load multiple levels of relationships in Eloquent?

What is the difference between empty(), isset(), != null, is_null() in PHP

What are the SPL data structures

How to find out which php.ini file PHP is using?

How to group a SQL statement in brackets/parenthesis