Article Directory
Stack
1.1 Definition of the stack
Stack (Stack) is a linear table that can only be inserted or deleted at one end.
The main feature of the stack is last in, first out.
1.2 Implementation of the sequential storage structure of the stack
Allocate a continuous storage area to store the elements in the stack, and use a variable to point to the top of the current stack.
The stack using sequential storage is called the sequential stack, and the Stack under the Java Util package is the sequential stack.
Stack application
Queue
2.1 Definition of queue
The queue is also a linear list with limited operations. It can only be deleted at one end and inserted at the other end.
api
java 集合类
数据结构 队列
底层 数组
绿色:了解
红色:重点
橘黄色:接口
维护
头、尾
offer(T t)
poll(T t) 获取并移除此队列的头,如果此队列为空,则返回 null
peek() 获取但不移除此队列的头;如果此队列为空,则返回 null
size()
Implementation of the sequential storage structure of the queue
Data structure: queue
bottom layer: array
Chain
Circular queue
Application of queue
The application scenarios of ordinary queues are limited. Generally, blocking queues (message queues) are used in engineering.
Blocking queues are often used in the producer-consumer model.
Thread pool: reduce overhead
Use queue implementation: BFS breadth-first search/traversal
Don’t repeat the wheel
Spring, framework CV rapid development