Salad  1.0.15
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
queue.h
Go to the documentation of this file.
1 /*
2  * Salad - An assortment of useful C stuff
3  * Copyright (C) 2016 Lloyd Dilley
4  * http://www.dilley.me/
5  *
6  * This file is part of Salad.
7  *
8  * Salad is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version
11  * 3 of the License, or (at your option) any later version.
12  *
13  * Salad is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with Salad. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
24 #ifndef QUEUE_H
25 #define QUEUE_H
26 
39 
41 typedef struct sld_queue
42 {
45  struct sld_list *list;
46  struct sld_vector *vector;
47 } sld_queue;
48 
61 SLD_SSINT sld_queue_init(struct sld_queue *queue, sld_queue_type queue_type);
62 
73 SLD_UINT sld_queue_size(struct sld_queue *queue);
74 
86 SLD_SSINT sld_queue_add(struct sld_queue *queue, void *object);
87 
98 void *sld_queue_remove(struct sld_queue *queue);
99 
110 void *sld_queue_peek(struct sld_queue *queue);
111 
121 void sld_queue_free(struct sld_queue *queue);
122 
125 #endif /* QUEUE_H */
struct sld_queue sld_queue
Definition: queue.h:41
SLD_UINT sld_queue_size(struct sld_queue *queue)
Returns the size of a sld_queue.
Definition: queue.c:80
sld_queue_type queue_type
Definition: queue.h:43
sld_queue_type
Definition: queue.h:38
struct sld_vector * vector
Definition: queue.h:46
SLD_UINT size
Definition: queue.h:44
void * sld_queue_remove(struct sld_queue *queue)
Returns and removes the first object in a sld_queue.
Definition: queue.c:101
void * sld_queue_peek(struct sld_queue *queue)
Returns the first object in a sld_queue.
Definition: queue.c:123
void sld_queue_free(struct sld_queue *queue)
Frees any memory allocated for an initialized sld_queue.
Definition: queue.c:136
SLD_SSINT sld_queue_init(struct sld_queue *queue, sld_queue_type queue_type)
Initializes a sld_queue.
Definition: queue.c:33
signed short int SLD_SSINT
Definition: types.h:47
Definition: list.h:44
Definition: vector.h:42
Definition: queue.h:38
unsigned int SLD_UINT
Definition: types.h:56
struct sld_list * list
Definition: queue.h:45
SLD_SSINT sld_queue_add(struct sld_queue *queue, void *object)
Adds an object to the start of a sld_queue.
Definition: queue.c:85
Definition: queue.h:38