46 lines
1.4 KiB
C
46 lines
1.4 KiB
C
// vim:fileencoding=utf-8:foldmethod=marker
|
|
|
|
#ifndef QUEUE_H
|
|
#define QUEUE_H
|
|
|
|
/* queue.h
|
|
|
|
Header file for queue implementation
|
|
*/
|
|
|
|
/* Copyright 2003-2020 by Steven S. Skiena; all rights reserved.
|
|
Permission is granted for use in non-commerical applications
|
|
provided this copyright notice remains intact and unchanged.
|
|
|
|
These programs appear in my books:
|
|
|
|
"The Algorithm Design Manual" by Steven Skiena, second edition, Springer,
|
|
London 2008. See out website www.algorist.com for additional information
|
|
or https://www.amazon.com/exec/obidos/ASIN/1848000693/thealgorith01-20
|
|
|
|
"Programming Challenges: The Programming Contest Training Manual"
|
|
by Steven Skiena and Miguel Revilla, Springer-Verlag, New York 2003.
|
|
See our website www.programming-challenges.com for additional information,
|
|
or https://www.amazon.com/exec/obidos/ASIN/0387001638/thealgorithmrepo/
|
|
*/
|
|
|
|
#include "item.h"
|
|
|
|
#define QUEUESIZE 1000
|
|
|
|
typedef struct {
|
|
item_type q[QUEUESIZE+1]; /* body of queue */
|
|
int first; /* position of first element */
|
|
int last; /* position of last element */
|
|
int count; /* number of queue elements */
|
|
} queue;
|
|
|
|
void init_queue(queue *q);
|
|
void enqueue(queue *q, item_type x);
|
|
item_type dequeue(queue *q);
|
|
item_type headq(queue *q);
|
|
int empty_queue(queue *q);
|
|
void print_queue(queue *q);
|
|
|
|
#endif // !QUEUE_H
|