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 destroy or remove a cookie in PHP

How to have a whitelist of IP addresses that can access files in .htaccess

How to check if a user is logged in, inside a blade file?

How to get the last character of a string in JS?

How to output (echo/print) content in PHP

Remove trailing slash (redirect to remove trailing slash) in .htaccess

How to prevent Eloquent from adding created_at or updated_at timestamps?

How to block IP addresses in Apache by using regular expressions (regex) in .htaccess

What are Apache MPMs?

An overview of every main PHP array function