实现循环链表头文件
This commit is contained in:
@@ -7,4 +7,6 @@ add_executable(test1
|
|||||||
Stack.h
|
Stack.h
|
||||||
Stack.cpp
|
Stack.cpp
|
||||||
test1.cpp)
|
test1.cpp)
|
||||||
add_executable(test2 test2.cpp)
|
add_executable(test2 test2.cpp
|
||||||
|
SeqQueue.cpp
|
||||||
|
SeqQueue.h)
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
//SeqQueue.cpp
|
||||||
|
|
||||||
|
#include "SeqQueue.h"
|
||||||
|
|
||||||
|
void initSeqQueue(SeqQueue &q) {
|
||||||
|
q.front = q.rear = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isEmpty(SeqQueue &q) {
|
||||||
|
if (q.front == q.rear) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isFull(SeqQueue &q) {
|
||||||
|
if ((q.rear + 1) % MAX_SIZE == q.front) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
//SeqQueue.h
|
||||||
|
|
||||||
|
#ifndef SEQQUEUE_H
|
||||||
|
#define SEQQUEUE_H
|
||||||
|
|
||||||
|
#define MAX_SIZE 100
|
||||||
|
|
||||||
|
typedef struct SeqQueue {
|
||||||
|
int data[MAX_SIZE];
|
||||||
|
int front, rear;
|
||||||
|
} SeqQueue;
|
||||||
|
|
||||||
|
void initSeqQueue(SeqQueue &q);
|
||||||
|
|
||||||
|
bool isEmpty(SeqQueue &q);
|
||||||
|
|
||||||
|
bool isFull(SeqQueue &q);
|
||||||
|
|
||||||
|
void enQueue(SeqQueue &q, int e);
|
||||||
|
|
||||||
|
int deQueue(SeqQueue &q);
|
||||||
|
|
||||||
|
#endif //SEQQUEUE_H
|
||||||
Reference in New Issue
Block a user