CObject
CIList.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_CILIST_H_
25 #define UTIL_CILIST_H_
26 
27 #include <Class.h>
28 #include <stdlib.h>
29 #include <CIIterator.h>
30 
31 
32 /************************************************************************/
33 /* Error codes */
34 /************************************************************************/
47 typedef enum
48 {
49  CILIST_OK = 0,
53 } CIListError;
54 
55 /************************************************************************/
56 /* Interface declaration. */
57 /************************************************************************/
69 struct CIList
70 {
71  /* CInterface must always be first member of */
72  /* an interface's struct .*/
73  struct CInterface interface;
74 };
75 
82 {
83  CIListError (*add)( struct CIList*, void* );
84  CIListError (*addAt)( struct CIList*, void*, size_t );
85  CIListError (*get)( struct CIList*, void*, size_t );
86  CIListError (*remove)( struct CIList*, void*, size_t );
87  void (*clear)( struct CIList* );
88  size_t (*size)( struct CIList* );
89  size_t (*maxSize)( struct CIList* );
90 };
91 
92 
93 /************************************************************************/
94 /* Member functions. */
95 /************************************************************************/
110 CIListError CIList_Add( struct CIList* self, void* element );
111 
127 CIListError CIList_AddAt( struct CIList* self, void* element, size_t index );
128 
146 CIListError CIList_Get( struct CIList* self, void* element, size_t index );
147 
164 CIListError CIList_Remove( struct CIList* self, void* element, size_t index );
165 
174 void CIList_Clear( struct CIList* self);
175 
185 size_t CIList_Size( struct CIList* self );
186 
196 size_t CIList_MaxSize( struct CIList* self );
197 
198 #endif /* UTIL_CILIST_H_ */
CIListError CIList_Add(struct CIList *self, void *element)
Definition: CIList.c:27
size_t CIList_Size(struct CIList *self)
Definition: CIList.c:62
void CIList_Clear(struct CIList *self)
Definition: CIList.c:55
Definition: CIList.h:51
CIListError
Definition: CIList.h:47
CIList virtual table.
Definition: CIList.h:81
Definition: CIList.h:49
Interface for list data structures.
Definition: CIList.h:69
Definition: CIList.h:50
Base interface.
Definition: Class.h:398
CIListError CIList_Get(struct CIList *self, void *element, size_t index)
Definition: CIList.c:41
CIListError CIList_Remove(struct CIList *self, void *element, size_t index)
Definition: CIList.c:48
CIListError CIList_AddAt(struct CIList *self, void *element, size_t index)
Definition: CIList.c:34
size_t CIList_MaxSize(struct CIList *self)
Definition: CIList.c:69
Definition: CIList.h:52