PHP standard library spl linked list, stack, queue
Doubly linked list class: SplDoublyLinkedList
1. Methods of adding and deleting nodes
push: Insert a node to the end of the linked list
pop: Get the tail node in the linked list and delete this node from the linked list; the operation does not change the position of the current pointer
unshift: Insert a node to the head of the linked list
shift: delete a linked list head node
2. Pointer operation method
rewind: make the current pointer of the linked list point to the head of the linked list (i.e. bottom)
current: Get the element pointed to by the current node pointer of the linked list. Rewind must be called before calling. When the pointed node is deleted, it will point to an empty node
next: Let the current pointer of the linked list point to the next node, and the return value of curent changes accordingly
bottom: Get the head element of the linked list, the current pointer position remains unchanged
top: Get the tail element of the linked list, the current pointer position remains unchanged
3. Other methods (see stack class for usage)
valid: Check whether there are still nodes in the linked list, it can be used as a judgment when looping output
count: counts the number of nodes in the linked list
key: Returns the key value of the current node
offsetSet: Set the value of the specified key. Note: If the key is 0, 0 points to the head or bottom in the linked list, and points to the top of the stack in the stack.
offunset: Unregister the value of the specified key
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
Stack class: SplStack class inherited from SplDoublyLinkedList class
Principle: The bottom layer of the stack class is implemented by the stack. The stack is a first-in, last-out data structure, so some of the SplStack class The methods inherited from the SplDoublyLinkedList class have some differences in understanding, such as the rewind method. After spl uses the rewind method, the pointer will point to the top of the stack in the picture. push and pop operate on the top elements of the stack, and unshift and shift operate on the bottom elements of the stack.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Queue class: SplQueue class inherited from SplDoublyLinkedList class
enqueue: Enter the queue
dequeue: Exit the queue
The rewind, offsetSet and other methods of the queue class are similar to the linked list
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
Copyright statement: This article is an original article by the blogger and may not be reproduced without the permission of the blogger.
The above has introduced the linked lists, stacks, and queues of the PHP standard library spl, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Convert basic data types to strings using Java's String.valueOf() function In Java development, when we need to convert basic data types to strings, a common method is to use the valueOf() function of the String class. This function can accept parameters of basic data types and return the corresponding string representation. In this article, we will explore how to use the String.valueOf() function for basic data type conversions and provide some code examples to

Method of converting char array to string: It can be achieved by assignment. Use {char a[]=" abc d\0efg ";string s=a;} syntax to let the char array directly assign a value to string, and execute the code to complete the conversion.

A dump file usually refers to a binary file, also known as a dump file or core dump file. This kind of file is generated by the computer system when it encounters a serious error or abnormal situation. It is used to store the status, stack, registers, memory images, logs and other information of the system or application.

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Replace characters (strings) in a string using Java's String.replace() function In Java, strings are immutable objects, which means that once a string object is created, its value cannot be modified. However, you may encounter situations where you need to replace certain characters or strings in a string. At this time, we can use the replace() method in Java's String class to implement string replacement. The replace() method of String class has two types:

Hello everyone, today I will share with you the basic knowledge of Java: String. Needless to say the importance of the String class, it can be said to be the most used class in our back-end development, so it is necessary to talk about it.

OPStack is an open source blockchain framework released by Optimism Collective, the development group behind the Optimism Network. It is an important tool for both the Ethereum and Optimism communities. The main goal of OPStack is to strengthen the Optimism Network, providing key software tools to the Optimism Mainnet, as well as the upcoming Optimism Superchain and its governance model. By providing a developer-oriented environment, the core idea of OPStack is to promote growth and innovation in the Ethereum space. It paves the way for cutting-edge developments and makes blockchain creation simpler. OPStac
