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 add the CSRF (Cross-site request forgery) token in Laravel?

How to set infinite execution time in a PHP script

What is the max size, by default, of GET variables?

How to set up an alias to map one directory to another destination

How to Extract Query String (from a URL) Into an Associative Array in PHP

What is the null coalescing operator in PHP7?

How to check if two strings are anagrams in PHP?

How to install jpegtran for Linux CentOS

How to prevent Eloquent from adding created_at or updated_at timestamps?

How to hide the server signature (hide Apache info) from HTTP headers with .htaccess