Data structure: Queue

Queue design and implementation

Queue basic concepts

A queue is a special kind of linear table

Queues operate only on both ends of the linear list

Front: Take out one end of the data element

Rear: the end of the inserted data element

Queues are not allowed to operate in the middle!

Common operations

destroy queue

empty the queue

into the queue

dequeue

Get the head element

Get the length of the queue

C language description ====="Queue design and realization of accumulation of wealth in life

#ifndef _MY_QUEUE_H_

#define _MY_QUEUE_H_

 

typedef void Queue;

 

Queue* Queue_Create();

 

void Queue_Destroy(Queue* queue);

 

void Queue_Clear(Queue* queue);

 

int Queue_Append(Queue* queue, void* item);

 

void* Queue_Retrieve(Queue* queue);

 

void* Queue_Header(Queue* queue);

 

int Queue_Length(Queue* queue);

 

#endif //_MY_QUEUE_H_

 

Design and implementation of sequential storage of queues

1. Basic Concepts

 

2. Design and implementation

#ifndef _MY_SEQQUEUE_H_

#define _MY_SEQQUEUE_H_

 

typedef void SeqQueue;

 

SeqQueue* SeqQueue_Create(int capacity);

 

void SeqQueue_Destroy(SeqQueue* queue);

 

void SeqQueue_Clear(SeqQueue* queue);

 

int SeqQueue_Append(SeqQueue* queue, void* item);

 

void* SeqQueue_Retrieve(SeqQueue* queue);

 

void* SeqQueue_Header(SeqQueue* queue);

 

int SeqQueue_Length(SeqQueue* queue);

 

int SeqQueue_Capacity(SeqQueue* queue);

 

#endif //_MY_SEQQUEUE_H_

 

 

队列的链式存储设计与实现

1、基本概念

 

2、设计与实现

#ifndef _MY_LINKQUEUE_H_

#define _MY_LINKQUEUE_H_

 

typedef void LinkQueue;

 

LinkQueue* LinkQueue_Create();

 

void LinkQueue_Destroy(LinkQueue* queue);

 

void LinkQueue_Clear(LinkQueue* queue);

 

int LinkQueue_Append(LinkQueue* queue, void* item);

 

void* LinkQueue_Retrieve(LinkQueue* queue);

 

void* LinkQueue_Header(LinkQueue* queue);

 

int LinkQueue_Length(LinkQueue* queue);

 

#endif //_MY_LINKQUEUE_H_

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325189422&siteId=291194637