What are the php data structures?

(*-*)浩
Release: 2023-02-25 06:58:01
Original
5109 people have browsed it

What are the data structures of php

What are the php data structures?

##Doubly linked list

Double linked list (DLL) is a list of nodes linked in two directions. When the underlying structure is a DLL, iterator operations, access to both ends, and addition or deletion of nodes all have an overhead of O(1). Therefore, it provides a suitable implementation for stacks and queues. (Recommended learning:

PHP programming from entry to proficiency)

Heap

The heap is a tree structure that follows the heap attributes: each node Greater than or equal to its children, compared using the implemented comparison method on the heap global.

Array

An array is a structure that stores data in a continuous manner and can be accessed through an index. Don't confuse them with PHP arrays: PHP arrays are actually implemented as ordered lists.

Mapping

Mapping is a data with key-value pairs. PHP arrays can be thought of as mappings from integers/strings to values. SPL provides mapping from objects to data. This map can also be used as an object set.

Stack Stack

is similar to a queue, a data structure with data storage characteristics.

Features: Data is stored in a first-in-last-out manner. The stack has only one outlet, and elements can only be added and removed from the top of the stack.

queue Queue

Features: First-in-first-out (FIFO), used in concurrency, can safely pass objects from one task to another.

set Set

Features: Save unique elements.

map Dictionary

Features: Associative array, also called dictionary or key-value pair.

graph Graph

Characteristics: Usually represented by adjacency matrices and adjacency tables. The former is easy to implement but will waste more space for sparse matrices. The latter Others use linked lists to store information, but the time complexity of graph search is high.

The above is the detailed content of What are the php data structures?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!