CObject
CIQueue.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Brendan Bruner
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * bbruner@ualberta.ca
17  * Jun 24, 2016
18  */
24 #ifndef UTIL_CIQUEUE_H_
25 #define UTIL_CIQUEUE_H_
26 
27 #include <Class.h>
28 
29 
30 /************************************************************************/
31 /* Error codes. */
32 /************************************************************************/
43 typedef enum
44 {
48 } CIQueueError;
49 
50 
51 /************************************************************************/
52 /* Declare interface and vtable. */
53 /************************************************************************/
70 struct CIQueue
71 {
72  /* CInterface must always be first member of */
73  /* an interfaces struct .*/
74  struct CInterface interface;
75 };
76 
83 {
84  CIQueueError (*insert)( struct CIQueue*, const void* );
85  CIQueueError (*remove)( struct CIQueue*, void* );
86  CIQueueError (*peek)( struct CIQueue*, void* );
87  size_t (*size)( struct CIQueue* );
88  size_t (*maxSize)( struct CIQueue* );
89  void (*clear)( struct CIQueue* );
90 };
91 
92 
93 /************************************************************************/
94 /* Class methods. */
95 /************************************************************************/
107 CIQueueError CIQueue_Insert( struct CIQueue* self, const void* element );
108 
122 CIQueueError CIQueue_Remove( struct CIQueue* self, void* element );
123 
137 CIQueueError CIQueue_Peek( struct CIQueue* self, void* element );
138 
148 size_t CIQueue_Size( struct CIQueue* self );
149 
159 size_t CIQueue_MaxSize( struct CIQueue* self );
160 
161 /*
162  * TODO: clear method should allow user to enter a clean up function.
163  */
172 void CIQueue_Clear( struct CIQueue* self );
173 
174 
175 #endif /* UTIL_CIQUEUE_H_ */
CIQueueError CIQueue_Insert(struct CIQueue *self, const void *element)
Definition: CIQueue.c:28
Definition: CIQueue.h:45
Definition: CIQueue.h:47
Definition: CIQueue.h:46
Base interface.
Definition: Class.h:398
CIQueueError CIQueue_Peek(struct CIQueue *self, void *element)
Definition: CIQueue.c:42
Queue data structure interface.
Definition: CIQueue.h:70
CIQueue virtual table.
Definition: CIQueue.h:82
size_t CIQueue_MaxSize(struct CIQueue *self)
Definition: CIQueue.c:56
CIQueueError CIQueue_Remove(struct CIQueue *self, void *element)
Definition: CIQueue.c:35
size_t CIQueue_Size(struct CIQueue *self)
Definition: CIQueue.c:49
CIQueueError
Definition: CIQueue.h:43
void CIQueue_Clear(struct CIQueue *self)
Definition: CIQueue.c:63