doc: create queue section in data structure post

This commit is contained in:
Leon Xu committed 2022-03-21 15:43:36 -07:00
1 parent e5df73392d
commit b004197569
1 file changed
+11 -1
+11 -1
View File
@@ -8,7 +8,7 @@ categories:
- 数据结构
abbrlink: 79666db
date: 2022-02-08 12:39:47
updated: 2022-03-15 17:00:00
updated: 2022-03-21 15:26:00
---
感觉好久没有更新网站了,一直在忙着修改简历和学习新的技术,所以就一直没有更新过。
今天呢,就跟大家说一下常见的数据结构,很多的教材有自己的分类,但是常见的数据结构有8大类![数据结构](/images/数据结构.png)
@@ -132,3 +132,13 @@ stack.push(num)
stack.peek() //will not remove, 只看栈顶
stack.pop() //栈顶元素弹出来
stack.isEmpty() //查看栈是否为空
## Queue 队列 First In First Out (FIFO)
![队列](/images/queue.png)
队列与栈一样,也是一种线性表,不同的是,队列可以在另一端添加元素,在另一端取出元素,也就是:先进先出。从一段放入元素的操作称为如对,取出元素为出队。
Queue<Integer> queue = new LinkedList<>();
queue.offer(1); //推荐
queue.offer(2);
queue.poll(); // return 1
queue.poll(); // return 2