00001 /* 00002 00003 Copyright (c) 2005-2008, Simon Howard 00004 00005 Permission to use, copy, modify, and/or distribute this software 00006 for any purpose with or without fee is hereby granted, provided 00007 that the above copyright notice and this permission notice appear 00008 in all copies. 00009 00010 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 00011 WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 00012 WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 00013 AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 00014 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 00015 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00016 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 00017 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00018 00019 */ 00020 00041 #ifndef ALGORITHM_QUEUE_H 00042 #define ALGORITHM_QUEUE_H 00043 00044 #ifdef __cplusplus 00045 extern "C" { 00046 #endif 00047 00052 typedef struct _Queue Queue; 00053 00058 typedef void *QueueValue; 00059 00064 #define QUEUE_NULL ((void *) 0) 00065 00073 Queue *queue_new(void); 00074 00081 void queue_free(Queue *queue); 00082 00093 int queue_push_head(Queue *queue, QueueValue data); 00094 00103 QueueValue queue_pop_head(Queue *queue); 00104 00114 QueueValue queue_peek_head(Queue *queue); 00115 00126 int queue_push_tail(Queue *queue, QueueValue data); 00127 00136 QueueValue queue_pop_tail(Queue *queue); 00137 00147 QueueValue queue_peek_tail(Queue *queue); 00148 00157 int queue_is_empty(Queue *queue); 00158 00159 #ifdef __cplusplus 00160 } 00161 #endif 00162 00163 #endif /* #ifndef ALGORITHM_QUEUE_H */ 00164