The SqQueue for Sequential queue (Continuous updates) | Data

简介: The code in Data book (5th Edition) from the 99 page to 100 page

The code in Data book (5th Edition) from the 99 page to 100 page

Continuous updates
#define MaxSize 50
typedef int ElemType;

typedef struct {
    ElemType data[MaxSize];
    int front,rear; //Team head and end pointer
} SqQueue;

//Initialize the queue
void InitQueue(SqQueue *&q) {
    q=(SqQueue *)malloc (sizeof(SqQueue));
    q->front=q->rear=-1;
}

//Destroy the queue
void DestroyQueue(SqQueue *&q) {
    free(q);
}

//Determine if the queue is empty
bool QueueEmpty(SqQueue *q) {
    return(q->front==q->rear);
}

//Into the queue
bool enQueue(SqQueue *&q, ElemType e) {
    if (q->rear==MaxSize-1) //The team was overflowing
        return false;
    q->rear++;
    q->data[q->rear]=e;
    return true;
}

//Out of the queue
bool deQueue(SqQueue *&q,ElemType &e) {
    if (q->front==q->rear) //The team empty overflow
        return false;
    q->front++;
    e=q->data[q->front];
    return true;
}
AI 代码解读
如有侵权,请联系作者删除
小饅頭
+关注
目录
打赏
0
0
0
0
75
分享
相关文章
Delta-CoMe:清华联合OpenBMB等高校开源的新型增量压缩算法
Delta-CoMe是由清华大学NLP实验室联合OpenBMB开源社区、北京大学和上海财经大学提出的新型增量压缩算法。该算法通过结合低秩分解和低比特量化技术,显著减少了大型语言模型的存储和内存需求,同时保持了模型性能几乎无损。Delta-CoMe特别适用于处理数学、代码和多模态等复杂任务,并在推理速度上有所提升。
203 6
Delta-CoMe:清华联合OpenBMB等高校开源的新型增量压缩算法
kik-net、peer、yjk、pkpm、midas、sac地震波格式互相转换
地震波格式转换、时程转换、峰值调整、规范反应谱、计算反应谱、计算持时、生成人工波、时频域转换、数据滤波、基线校正、Arias截波、傅里叶变换、耐震时程曲线、脉冲波合成与提取、三联反应谱、地震动参数、延性反应谱、地震波缩尺、功率谱密度
「天池AI IP形象征集大赛」重磅上线,天池平台Al形象由你来创造!
聚首十年,以文生景,靠想象勾勒非凡,更有丰厚参赛奖励!
Files.find 去除部分目录/dev/fd,/proc如何操作
在使用 `Files.find` 方法时,如果你想在搜索过程中排除特定目录,如 `/dev/fd` 和 `/proc`,可以在 `BiPredicate` 实现中添加相应的逻辑。以下是一个示例,演示如何在 `Files.find` 中排除这些目录: ```java import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; imp
120 0
【C++入门到精通】智能指针 shared_ptr循环引用 | weak_ptr 简介及C++模拟实现 [ C++入门 ]
【C++入门到精通】智能指针 shared_ptr循环引用 | weak_ptr 简介及C++模拟实现 [ C++入门 ]
459 0
[NPUCTF2020]ezlogin (xpath盲注)
[NPUCTF2020]ezlogin (xpath盲注)
265 0
「趣学前端」关于iframe跨域通信
用技术实现梦想,用梦想打开创意之门。之前开发遇到了iframe跨域通信的问题,今天分享一下解决方案,顺便总结一波知识点。
1220 1
「趣学前端」关于iframe跨域通信

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等