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;
}
如有侵权,请联系作者删除
目录
相关文章
|
3月前
|
TensorFlow 算法框架/工具
【Tensorflow】解决A `Concatenate` layer should be called on a list of at least 2 inputs
在TensorFlow 2.0中,使用Concatenate函数时出现错误,可以通过替换为tf.concat 来解决。
42 4
Expected more than 1 value per channel when training, got input size torch.Size
因为模型中用了batchnomolization,训练中用batch训练的时候当前batch恰好只含一个sample,而由于BatchNorm操作需要多于一个数据计算平均值,因此造成该错误。
905 0
|
机器学习/深度学习 算法 图形学
Deep learning based multi-scale channel compression feature surface defect detection system
简述:首先应用背景分割和模板匹配技术来定义覆盖目标工件的ROI区域。提取的感兴趣区域被均匀地裁剪成若干个图像块,每个块被送到基于CNN的模型,以分类杂乱背景中不同大小的表面缺陷。最后,对空间上相邻且具有相同类别标签的图像块进行合并,以生成各种表面缺陷的识别图。
151 0
The LinkQuNode for Linked queue (Continuous updates) | Data
The code in Data book (5th Edition) from the 105 page to 106 page
94 0
The Sqstack for Sequential stack | Data
The some code in Data book (5th Edition) from the 81 page to 82 page
85 0
|
PyTorch 算法框架/工具
【Pytorch问题】RuntimeError: “max_pool2d“ not implemented for ‘Long‘
【Pytorch问题】RuntimeError: “max_pool2d“ not implemented for ‘Long‘
353 0
|
Linux PyTorch 算法框架/工具
Some weights of the model checkpoint at mypath/bert-base-chinese were not used when initializing Ber
Some weights of the model checkpoint at mypath/bert-base-chinese were not used when initializing Ber
|
缓存
AS项目一直Indexing paused due to batch updated
AS项目一直Indexing paused due to batch updated
143 0
|
存储
PAT (Advanced Level) Practice - 1051 Pop Sequence(25 分)
PAT (Advanced Level) Practice - 1051 Pop Sequence(25 分)
100 0
|
BI
Five Steps to Becoming a Better Data Analyst
In this post, a data analyst from wangjubao.com, a leading data-marketing firm in China, shares some advice on making better data insights.
1897 0
Five Steps to Becoming a Better Data Analyst