root / trunk / code / projects / slam.bak2 / computer / queue.h @ 722
History | View | Annotate | Download (2.34 KB)
1 |
/**
|
---|---|
2 |
* Copyright (c) 2007 Colony Project
|
3 |
*
|
4 |
* Permission is hereby granted, free of charge, to any person
|
5 |
* obtaining a copy of this software and associated documentation
|
6 |
* files (the "Software"), to deal in the Software without
|
7 |
* restriction, including without limitation the rights to use,
|
8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
* copies of the Software, and to permit persons to whom the
|
10 |
* Software is furnished to do so, subject to the following
|
11 |
* conditions:
|
12 |
*
|
13 |
* The above copyright notice and this permission notice shall be
|
14 |
* included in all copies or substantial portions of the Software.
|
15 |
*
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23 |
* OTHER DEALINGS IN THE SOFTWARE.
|
24 |
**/
|
25 |
|
26 |
/**
|
27 |
* @file queue.h
|
28 |
* @brief A queue implementation
|
29 |
*
|
30 |
* Implements a queue, a first in, first out data structure.
|
31 |
*
|
32 |
* @author Brian Coltin, Colony Project, CMU Robotics Club
|
33 |
**/
|
34 |
|
35 |
#ifndef WIRELESS_QUEUE_H
|
36 |
#define WIRELESS_QUEUE_H
|
37 |
|
38 |
struct node_def;
|
39 |
|
40 |
/**
|
41 |
* @defgroup queue Queue
|
42 |
* @brief A queue implementation
|
43 |
*
|
44 |
* A queue implementation.
|
45 |
*
|
46 |
* @{
|
47 |
**/
|
48 |
|
49 |
/**
|
50 |
* @struct Queue
|
51 |
* Represents a queue, a first in, first out data structure.
|
52 |
**/
|
53 |
typedef struct |
54 |
{ |
55 |
/**
|
56 |
* The head of the queue, the next item to be removed.
|
57 |
**/
|
58 |
struct node_def* head;
|
59 |
/**
|
60 |
* The tail of the queue, the last item added.
|
61 |
**/
|
62 |
struct node_def* tail;
|
63 |
/**
|
64 |
* The number of elements in the queue.
|
65 |
**/
|
66 |
int size;
|
67 |
} Queue; |
68 |
|
69 |
/** @brief Create a new queue **/
|
70 |
Queue* queue_create(void);
|
71 |
/** @brief Destroy a queue **/
|
72 |
void queue_destroy(Queue* q);
|
73 |
/** @brief Add an element to a queue **/
|
74 |
void queue_add(Queue* q, void* item); |
75 |
/** @brief Remove an element from a queue **/
|
76 |
void* queue_remove(Queue* q);
|
77 |
/** @brief Remove all instances of a given element from a queue **/
|
78 |
void queue_remove_all(Queue* q, void* item); |
79 |
/** @brief Get the size of a queue **/
|
80 |
int queue_size(Queue* q);
|
81 |
/** @brief Check if the queue is empty **/
|
82 |
int queue_is_empty(Queue* q);
|
83 |
|
84 |
/** @} **/
|
85 |
|
86 |
|
87 |
#endif
|
88 |
|