【数据结构初阶】栈和队列
栈和队列
- 1.栈
- 1.1栈的概念和结构
- 1.2栈的实现
- 2.队列
- 2.1队列的概念和结构
- 2.2队列的实现
1.栈
1.1栈的概念和结构
栈:一种特殊的线性表,其只允许在固定的一端进行插入和删除元素操作。进行数据插入和删除操作的一端称为栈顶,另一端称为栈底。栈中的数据元素遵守后进先出LIFO(Last In First Out)的原则。
压栈:栈的插入操作叫做进栈/压栈/入栈,入数据在栈顶。
出栈:栈的删除操作叫做出栈。出数据也在栈顶。


1.2栈的实现
栈的实现一般可以使用数组或者链表实现,相对而言数组的结构实现更优一些。因为数组在尾上插入数据的代价比较小


Stack.h
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<stdbool.h>typedef int STDateType;
typedef struct Stack
{STDateType* a;int top;int capacity;
}ST;//初始化
void STInit(ST* ps);//销毁
void STDestroy(ST* ps);//入栈
void STPush(ST* ps, STDateType x);//出栈
void STPop(ST* ps);//栈顶
STDateType SLTTop(ST* ps);//计算大小
int STSize(ST* ps);//判断是否为空
bool STEmpty(ST* ps);
Stack.c
#include"Stack.h"//初始化
void STInit(ST* ps)
{assert(ps);ps->capacity = NULL;ps->a = 0;ps->top = 0;
}//销毁
void STDestroy(ST* ps)
{assert(ps);free(ps->a);ps->a = NULL;ps->capacity = ps->top = 0;
}//入栈
void STPush(ST* ps, STDateType x)
{assert(ps);if (ps->top == ps->capacity){int NewCapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;STDateType* tmp = (STDateType*)realloc(ps->a, sizeof(STDateType) * NewCapacity);if (tmp == NULL){perror("realloc fail");exit(-1);}ps->a = tmp;ps->capacity = NewCapacity;}ps->a[ps->top] = x;ps->top++;
}//出栈
void STPop(ST* ps)
{assert(ps);assert(ps->a > 0);--ps->top;
}//栈顶
STDateType STTop(ST* ps)
{assert(ps);assert(ps->a > 0);return ps->a[ps->top - 1];
}//计算
int STSize(ST* ps)
{assert(ps);return ps->top;
}//判断是否为空
bool STEmpty(ST* ps)
{assert(ps);return ps->top == NULL;
}
test.c
#include"Stack.h"void TestStack()
{ST st;STInit(&st);STPush(&st, 1);STPush(&st, 2);STPush(&st, 3);STPush(&st, 4);STPush(&st, 5);while (!STEmpty(&st)){printf("%d ", STTop(&st));STPop(&st);}printf("\n");STDestroy(&st);
}int main()
{TestStack();return 0;
}
2.队列
2.1队列的概念和结构
队列:只允许在一端进行插入数据操作,在另一端进行删除数据操作的特殊线性表,队列具有先进先出FIFO(First In First Out) 入队列:进行插入操作的一端称为队尾出队列:进行删除操作的一端称为队头

2.2队列的实现
队列也可以数组和链表的结构实现,使用链表的结构实现更优一些,因为如果使用数组的结构,出队列在数组头上出数据,效率会比较低。

Queue.h
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<stdbool.h>
typedef int QDataType;
typedef struct QueueNode
{struct QueueNode* next;QDataType data;
}QNode;
typedef struct Queue
{QNode* head;QNode* tail;int size;
}Que;
void QueueInit(Que* pq);
void QueueDestroy(Que* pq);
void QueuePush(Que* pq, QDataType x);
void QueuePop(Que* pq);
QDataType QueueFront(Que* pq);
QDataType QueueBack(Que* pq);
bool QueueEmpty(Que* pq);
int QueueSize(Que* pq);
Queue.c
#include"Queue.h"//初始化
void QueueInit(Que* pq)
{assert(pq);pq->head = pq->tail = NULL;pq->size = 0;
}//销毁
void QueueDestroy(Que* pq)
{assert(pq);QNode* cur = pq->head;while (cur){QNode* next = cur->next;free(cur);cur = cur->next;}pq->head = pq->tail = NULL;pq->size = 0;
}//入队
void QueuePush(Que* pq, QDateType x)
{assert(pq);QNode* newnode = (QNode*)malloc(sizeof(QNode));if (newnode == NULL){perror("malloc fail");exit(-1);}newnode->date = x;newnode->next = NULL;if (pq->tail == NULL){pq->head = pq->tail = newnode;}else{pq->tail->next = newnode;pq->tail = newnode;}pq->size++;
}//出队
void QueuePop(Que* pq)
{assert(pq);assert(!QueueEmpty(pq));if (pq->head->next == NULL){pq->head = pq->tail = NULL;}else{QNode* next = pq->head->next;free(pq->head);pq->head = next;}pq->size--;
}//队头
QDateType QueueFront(Que* pq)
{assert(pq);assert(!QueueEmpty(pq));return pq->head->date;
}//队尾
QDateType QueueBack(Que* pq)
{assert(pq);assert(!QueueEmpty);return pq->tail->date;
}//判断是否为空
bool QueueEmpty(Que* pq)
{assert(pq);return pq->head == NULL;
}//计算
int QueueSize(Que* pq)
{assert(pq);return pq->size;
}
test.c
#include"Queue.h"void QueueTest()
{Que pq;QueueInit(&pq);QueuePush(&pq, 1);QueuePush(&pq, 2);QueuePush(&pq, 3);QueuePush(&pq, 4);while (!QueueEmpty(&pq)){printf("%d ", QueueFront(&pq));QueuePop(&pq);}printf("\n");QueueDestroy(&pq);
}int main()
{QueueTest();return 0;
}
3.栈和队列面试题
3.1括号匹配问题
OJ
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<stdbool.h>
//有效括号
typedef char STDateType;
typedef struct Stack
{STDateType* a;int top;int capacity;
}ST;
//初始化
void STInit(ST* ps);
//销毁
void STDestroy(ST* ps);
//入栈
void STPush(ST* ps, STDateType x);
//出栈
void STPop(ST* ps);
//栈顶
STDateType SLTTop(ST* ps);
//计算大小
int STSize(ST* ps);
//判断是否为空
bool STEmpty(ST* ps);//初始化
void STInit(ST* ps)
{assert(ps);ps->capacity = NULL;ps->a = 0;ps->top = 0;
}
//销毁
void STDestroy(ST* ps)
{assert(ps);free(ps->a);ps->a = NULL;ps->capacity = ps->top = 0;
}
//入栈
void STPush(ST* ps, STDateType x)
{assert(ps);if (ps->top == ps->capacity){int NewCapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;STDateType* tmp = (STDateType*)realloc(ps->a, sizeof(STDateType) * NewCapacity);if (tmp == NULL){perror("realloc fail");exit(-1);}ps->a = tmp;ps->capacity = NewCapacity;}ps->a[ps->top] = x;ps->top++;
}
//出栈
void STPop(ST* ps)
{assert(ps);assert(ps->a > 0);--ps->top;
}
//栈顶
STDateType STTop(ST* ps)
{assert(ps);assert(ps->a > 0);return ps->a[ps->top - 1];
}
//计算
int STSize(ST* ps)
{assert(ps);return ps->top;
}
//判断是否为空
bool STEmpty(ST* ps)
{assert(ps);return ps->top == NULL;
}bool isValid(char* s)
{ST st;STInit(&st);char topVal;while (*s){//数量不匹配if (*s == '(' || *s == '[' || *s == '{'){STPush(&st, *s);}else{if (STEmpty(&st)){STDestroy(&st);return false;}topVal = STTop(&st);STPop(&st);if ((*s == ')' && topVal != '(') || (*s == ']' && topVal != '[') || (*s == ' }' && topVal != '{')){STDestroy(&st);return false;}}s++;}//栈不为空,false,说明数量不匹配bool ret = STEmpty(&st);STDestroy(&st);return ret;
}int main()
{isValid("[(({})}]");#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<stdbool.h>
typedef int STDateType;
typedef struct Stack
{STDateType* a;int top;int capacity;
}ST;
//初始化
void STInit(ST* ps);
//销毁
void STDestroy(ST* ps);
//入栈
void STPush(ST* ps, STDateType x);
//出栈
void STPop(ST* ps);
//栈顶
STDateType SLTTop(ST* ps);
//计算大小
int STSize(ST* ps);
//判断是否为空
bool STEmpty(ST* ps);
//初始化
void STInit(ST* ps)
{assert(ps);ps->capacity = NULL;ps->a = 0;ps->top = 0;
}
//销毁
void STDestroy(ST* ps)
{assert(ps);free(ps->a);ps->a = NULL;ps->capacity = ps->top = 0;
}
//入栈
void STPush(ST* ps, STDateType x)
{assert(ps);if (ps->top == ps->capacity){int NewCapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;STDateType* tmp = (STDateType*)realloc(ps->a, sizeof(STDateType) * NewCapacity);if (tmp == NULL){perror("realloc fail");exit(-1);}ps->a = tmp;ps->capacity = NewCapacity;}ps->a[ps->top] = x;ps->top++;
}
//出栈
void STPop(ST* ps)
{assert(ps);assert(ps->a > 0);--ps->top;
}
//栈顶
STDateType STTop(ST* ps)
{assert(ps);assert(ps->a > 0);return ps->a[ps->top - 1];
}
//计算
int STSize(ST* ps)
{assert(ps);return ps->top;
}
//判断是否为空
bool STEmpty(ST* ps)
{assert(ps);return ps->top == NULL;
}
typedef struct
{ST pushst;ST popst;
} MyQueue;
MyQueue* myQueueCreate()
{MyQueue* obj = (MyQueue*)malloc(sizeof(MyQueue));STInit(&obj->popst);STInit(&obj->pushst);return obj;
}void myQueuePush(MyQueue* obj, int x)
{STPush(&obj->pushst, x);
}int myQueuePeek(MyQueue* obj)
{if (STEmpty(&obj->popst)){while (!STEmpty(&obj->pushst)){STPush(&obj->popst, STTop(&obj->pushst));STPop(&obj->pushst);}}return STTop(&obj->popst);
}int myQueuePop(MyQueue* obj)
{int front = myQueuePeek(obj);STPop(&obj->popst);return front;
}bool myQueueEmpty(MyQueue* obj)
{return STEmpty(&obj->popst) && STEmpty(&obj->pushst);
}void myQueueFree(MyQueue* obj)
{STDestroy(&obj->popst);STDestroy(&obj->pushst);free(obj);
}}
3.2用队列实现栈
OJ


3.3用栈实现队列
OJ

#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<stdbool.h>
typedef int STDateType;
typedef struct Stack
{STDateType* a;int top;int capacity;
}ST;
//初始化
void STInit(ST* ps);
//销毁
void STDestroy(ST* ps);
//入栈
void STPush(ST* ps, STDateType x);
//出栈
void STPop(ST* ps);
//栈顶
STDateType SLTTop(ST* ps);
//计算大小
int STSize(ST* ps);
//判断是否为空
bool STEmpty(ST* ps);
//初始化
void STInit(ST* ps)
{assert(ps);ps->capacity = NULL;ps->a = 0;ps->top = 0;
}
//销毁
void STDestroy(ST* ps)
{assert(ps);free(ps->a);ps->a = NULL;ps->capacity = ps->top = 0;
}
//入栈
void STPush(ST* ps, STDateType x)
{assert(ps);if (ps->top == ps->capacity){int NewCapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;STDateType* tmp = (STDateType*)realloc(ps->a, sizeof(STDateType) * NewCapacity);if (tmp == NULL){perror("realloc fail");exit(-1);}ps->a = tmp;ps->capacity = NewCapacity;}ps->a[ps->top] = x;ps->top++;
}
//出栈
void STPop(ST* ps)
{assert(ps);assert(ps->a > 0);--ps->top;
}
//栈顶
STDateType STTop(ST* ps)
{assert(ps);assert(ps->a > 0);return ps->a[ps->top - 1];
}
//计算
int STSize(ST* ps)
{assert(ps);return ps->top;
}
//判断是否为空
bool STEmpty(ST* ps)
{assert(ps);return ps->top == NULL;
}
typedef struct
{ST pushst;ST popst;
} MyQueue;
MyQueue* myQueueCreate()
{MyQueue* obj = (MyQueue*)malloc(sizeof(MyQueue));STInit(&obj->popst);STInit(&obj->pushst);return obj;
}void myQueuePush(MyQueue* obj, int x)
{STPush(&obj->pushst, x);
}int myQueuePeek(MyQueue* obj)
{if (STEmpty(&obj->popst)){while (!STEmpty(&obj->pushst)){STPush(&obj->popst, STTop(&obj->pushst));STPop(&obj->pushst);}}return STTop(&obj->popst);
}int myQueuePop(MyQueue* obj)
{int front = myQueuePeek(obj);STPop(&obj->popst);return front;
}bool myQueueEmpty(MyQueue* obj)
{return STEmpty(&obj->popst) && STEmpty(&obj->pushst);
}void myQueueFree(MyQueue* obj)
{STDestroy(&obj->popst);STDestroy(&obj->pushst);free(obj);
}
3.4设计循环队列
OJ


#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<stdbool.h>
//计循环队列
typedef struct
{int* a;int front;int rear;int k;
} MyCircularQueue;MyCircularQueue* myCircularQueueCreate(int k)
{MyCircularQueue* obj = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));obj->a = (int*)malloc(sizeof(int) * (k + 1));obj->front = obj->rear = 0;obj->k = k;return obj;
}bool myCircularQueueIsEmpty(MyCircularQueue* obj)
{return obj->front == obj->rear;
}bool myCircularQueueIsFull(MyCircularQueue* obj)
{return (obj->rear + 1) % (obj->k + 1) == obj->front;
}bool myCircularQueueEnQueue(MyCircularQueue* obj, int value)
{if (myCircularQueueIsFull(obj))return false;obj->a[obj->rear] = value;obj->rear++;obj->rear %= (obj->k + 1);return true;
}bool myCircularQueueDeQueue(MyCircularQueue* obj)
{if (myCircularQueueIsEmpty(obj))return false;obj->front++;obj->front %= (obj->k + 1);return true;
}int myCircularQueueFront(MyCircularQueue* obj)
{if (myCircularQueueIsEmpty(obj))return -1;return obj->a[obj->front];
}int myCircularQueueRear(MyCircularQueue* obj)
{if (myCircularQueueIsEmpty(obj))return -1;return obj->a[(obj->rear + obj->k) % (obj->k + 1)];
}void myCircularQueueFree(MyCircularQueue* obj)
{free(obj->a);free(obj);
}
💘不知不觉,【数据结构初阶】栈和队列以告一段落。通读全文的你肯定收获满满,让我们继续为数据结构学习共同奋进!!!
相关文章:
【数据结构初阶】栈和队列
栈和队列 1.栈1.1栈的概念和结构1.2栈的实现 2.队列2.1队列的概念和结构2.2队列的实现 1.栈 1.1栈的概念和结构 栈:一种特殊的线性表,其只允许在固定的一端进行插入和删除元素操作。进行数据插入和删除操作的一端称为栈顶,另一端称为栈底。…...
MATLAB - text的两种使用方法
text小技巧 1. 常规使用(Method 1)2. 在显示画面的相对位置(Method 2)3. 举个例子 1. 常规使用(Method 1) text(x,y,txt)2. 在显示画面的相对位置(Method 2) text(string,‘ABC’,…...
ubuntu下配置qtcreator交叉编译环境
文章目录 安装交叉编译工具安装qt creator开发环境配置交叉编译示例demo参考 安装交叉编译工具 安装qt creator开发环境 1 官网 2 填写信息 3 下载 默认没有出现Qt5.15版本 WISONIC\80081001ub16-1001:~$ /opt/Qt/Tools/QtCreator/bin/qtcreator /opt/Qt/Tools/QtCreat…...
金风玉露一相逢|实在智能联手浪潮信息合力致新生成式AI产业生态
近日,实在智能正式加入浪潮信息元脑生态AIStore。 实在智能是一家基于AGI大模型超自动化技术,领跑人机协同时代的人工智能科技公司,以其自研垂直的“TARS(塔斯)大语言模型”技术、实在RPA Agent智能体数字员工产品和超…...
Design Guidelines for 100 Gbps
文章目录 Stratix V GT Transceiver ChannelsCFP2 Host Connector Assembly and PinoutStratix V GT to CFP2 Interface Layout DesignBoard Stack Up DimensionsExample Design Channel PerformanceSimulation Results for Stratix V GT to CFP2 Connector Layout Design Desi…...
苹果企业账号申请思考
苹果企业账号 好多年的企业账号想启用,但是没有找到入口,直接联系了一下苹果的技术支持。通过邮件联系,之后他们回电,吧啦吧啦问了一大堆关于企业账号的事情,他们对这个还挺关注的,主要是集中在是否是有必…...
【C/C++】素数专题
素数专题 1.判断素数模板2.求范围内的素数(101-200)3.判断素数与分解 1.判断素数模板 #include<stdio.h> #include<math.h>int prism(int n){if(n1) return 0;for(int i2;i<sqrt(n);i){if(n%i0) return 0;}return 1; }int main() {int n…...
Apple Vision Pro 开发机申请
申请地址: (免费租用形式) Developer Kit - visionOS - Apple Developer 上海Apple Lab 互动申请: View - Meet with Apple Experts - Apple Developer (需要完善的产品才能去测试哦) 它是如何工作的 我们将借给你一个Apple Vision Pro开发…...
NFS服务器搭建 配置nfs共享目录
一定要用二级目录,否则NFS坏了主机都启动不起来 一级目录是强制挂载,二级目录是动态挂载 nfs共享远程目录具体步骤: 服务器端配置: 1.安装NFS服务器软件 sudo apt-get install nfs-kernel-server # 安装 NFS服务器端 2.添加…...
springboot+bootstrap+java农业电商服务商城系统_30249
本农业电商服务系统是为了提高用户查阅信息的效率和管理人员管理信息的工作效率,可以快速存储大量数据,还有信息检索功能,这大大的满足了管理员、会员和商家这三者的需求。操作简单易懂,合理分析各个模块的功能,尽可能…...
【shell】脚本实现将开发机user1账户下的abc文件夹复制到user2~4账户下
1 主要内容 可以使用Shell脚本来实现将开发机(Linux)上user1账户下的abc文件夹复制到user2、user3和user4账户下。 #!/bin/bash# 数组赋值,目标用户列表 # target_users(user2 user3 user4) # 定义数组 target_users()# 生成user数字的数组…...
steamui.dll找不到指定模块,要怎么修复steamui.dll文件
当我们使用Steam进行游戏时,有时可能会面对一些令人无奈的技术问题。一种常见的问题是“找不到指定模块steamui.dll”,这可能是由于缺少文件、文件损坏或软件冲突等原因导致。但别担心,这篇文章将提供几种解决此问题的方法,并针对…...
鸿蒙原生应用/元服务开发-AGC分发如何上架HarmonyOS应用
一、上架整体流程 二、上架HarmonyOS应用 获取到HarmonyOS应用软件包后,开发者可将应用提交至AGC申请上架。上架成功后,用户即可在华为应用市场搜索获取开发者的HarmonyOS应用。 配置应用信息 1.登录AppGallery Connect,选择“我的应用”。…...
基于单片机仓库温湿度监测报警系统仿真设计
**单片机设计介绍,基于单片机仓库温湿度监测报警系统仿真设计 文章目录 一 概要二、功能设计设计思路 三、 软件设计原理图 五、 程序六、 文章目录 一 概要 基于单片机的仓库温湿度监测报警系统可以被设计成能够实时监测仓库内的温度和湿度,并根据预设…...
中文rlhf数据集50w条数据解析
中文rlhf数据集50w条数据解析 解析代码数据名代码解析 解析代码 import jieba from tqdm import tqdm import re import pandas as pd import numpy as npdef find_non_english_text(text):pattern re.compile(r[^a-zA-Z])return pattern.sub(, text)def find_chinese_text(t…...
解决解析PDF编码报错(以pdfminer为例):UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte xxx
解决方法 博主使用的是pdfminer解析PDF文档,这个解决方法是通用的,只需要使PDFParser传入的文件为二进制文件即可,示例程序: from pdfminer.pdfparser import PDFParserpdf_parser PDFParser(open("pdf文件.pdf", &q…...
chatGPT2:如何构建一个可以回答有关您网站问题的 AI 嵌入(embeddings)
感觉这个目前没有什么用,因为客户可以直接问通用chatGPT,实时了解你网站内的信息,除非你的网站chatGPT无法访问。 不过自动预订、买票等用嵌入还是挺有用的。 什么是嵌入? OpenAI的嵌入(embeddings)是一种…...
Vue3-新特性defineOptions和defineModel
defineOptions 问题:用了<script setup>后,就无法添加与其平级的属性了,比如定义组件的name或其他自定义的属性。 为了解决这一问题,引入了defineProps与defineEmits这两个宏,但这只解决了props与emits这两个属…...
【计算机基础】通过插件plantuml,实现在VScode里面绘制状态机
📢:如果你也对机器人、人工智能感兴趣,看来我们志同道合✨ 📢:不妨浏览一下我的博客主页【https://blog.csdn.net/weixin_51244852】 📢:文章若有幸对你有帮助,可点赞 👍…...
Linux常用基础命令及重要目录,配置文件功能介绍
目录 一,Linux常用必备基础命令 1,网络类命令 2,文件目录类命令 3,操作类命令 4,关机重启命令 5,帮助命令 6,查看显示类命令 7,命令常用快捷键 二,Linux重要目录…...
后进先出(LIFO)详解
LIFO 是 Last In, First Out 的缩写,中文译为后进先出。这是一种数据结构的工作原则,类似于一摞盘子或一叠书本: 最后放进去的元素最先出来 -想象往筒状容器里放盘子: (1)你放进的最后一个盘子(…...
云原生核心技术 (7/12): K8s 核心概念白话解读(上):Pod 和 Deployment 究竟是什么?
大家好,欢迎来到《云原生核心技术》系列的第七篇! 在上一篇,我们成功地使用 Minikube 或 kind 在自己的电脑上搭建起了一个迷你但功能完备的 Kubernetes 集群。现在,我们就像一个拥有了一块崭新数字土地的农场主,是时…...
376. Wiggle Subsequence
376. Wiggle Subsequence 代码 class Solution { public:int wiggleMaxLength(vector<int>& nums) {int n nums.size();int res 1;int prediff 0;int curdiff 0;for(int i 0;i < n-1;i){curdiff nums[i1] - nums[i];if( (prediff > 0 && curdif…...
Qwen3-Embedding-0.6B深度解析:多语言语义检索的轻量级利器
第一章 引言:语义表示的新时代挑战与Qwen3的破局之路 1.1 文本嵌入的核心价值与技术演进 在人工智能领域,文本嵌入技术如同连接自然语言与机器理解的“神经突触”——它将人类语言转化为计算机可计算的语义向量,支撑着搜索引擎、推荐系统、…...
ffmpeg(四):滤镜命令
FFmpeg 的滤镜命令是用于音视频处理中的强大工具,可以完成剪裁、缩放、加水印、调色、合成、旋转、模糊、叠加字幕等复杂的操作。其核心语法格式一般如下: ffmpeg -i input.mp4 -vf "滤镜参数" output.mp4或者带音频滤镜: ffmpeg…...
Axios请求超时重发机制
Axios 超时重新请求实现方案 在 Axios 中实现超时重新请求可以通过以下几种方式: 1. 使用拦截器实现自动重试 import axios from axios;// 创建axios实例 const instance axios.create();// 设置超时时间 instance.defaults.timeout 5000;// 最大重试次数 cons…...
C++ 求圆面积的程序(Program to find area of a circle)
给定半径r,求圆的面积。圆的面积应精确到小数点后5位。 例子: 输入:r 5 输出:78.53982 解释:由于面积 PI * r * r 3.14159265358979323846 * 5 * 5 78.53982,因为我们只保留小数点后 5 位数字。 输…...
(转)什么是DockerCompose?它有什么作用?
一、什么是DockerCompose? DockerCompose可以基于Compose文件帮我们快速的部署分布式应用,而无需手动一个个创建和运行容器。 Compose文件是一个文本文件,通过指令定义集群中的每个容器如何运行。 DockerCompose就是把DockerFile转换成指令去运行。 …...
GruntJS-前端自动化任务运行器从入门到实战
Grunt 完全指南:从入门到实战 一、Grunt 是什么? Grunt是一个基于 Node.js 的前端自动化任务运行器,主要用于自动化执行项目开发中重复性高的任务,例如文件压缩、代码编译、语法检查、单元测试、文件合并等。通过配置简洁的任务…...
LRU 缓存机制详解与实现(Java版) + 力扣解决
📌 LRU 缓存机制详解与实现(Java版) 一、📖 问题背景 在日常开发中,我们经常会使用 缓存(Cache) 来提升性能。但由于内存有限,缓存不可能无限增长,于是需要策略决定&am…...
