Efficient data structures for PHP 7

“What about the SPL data structures?”

“Why can’t we just fix and improve them?”

Collection

Sequence

Vector

The number one data structure used in Photoshop was Vectors.” — Sean Parent, CppCon 2015

Deque

Stack

Queue

PriorityQueue

“So… why an array?”

Hashable

Map

Set

Responses to expected questions and opinions

Are there tests?

Documentation? API reference?

Can we see how the benchmarks were configured? Are there more of them?

Why are Stack, Queue, Set, and Map not interfaces?

When should I use a Deque rather than a Vector?

Why are all the classes final?

Just because these structures don’t extend each other doesn't mean that we shouldn't be allowed to either.

Why no linked list?

Would a linked list have lower peak memory because there’s no buffer?

Okay… so a linked list uses more memory. But why is it slow?

“Discontiguous data structures are the root of all performance evil. Specifically, please say no to linked lists.”

“There is almost nothing more harmful you can do to the performance of an actual modern microprocessor than to use a linked list data structure.”

— Chandler Carruth (CppCon 2014)

PHP is a web development language — performance is not important.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store