Coconut Framework  beta
CNList.h
Go to the documentation of this file.
1 
8 #ifndef CNLIST_H
9 #define CNLIST_H
10 
11 #include "CNListItem.h"
12 #include "CNType.h"
13 
17 struct CNList {
19  struct CNResource * resource ;
21  size_t itemCount ;
24 } ;
25 
31 static inline struct CNList
32 CNMakeEmptyList(struct CNResource * resource)
33 {
34  struct CNList list ;
35  list.resource = resource ;
36  list.itemCount = 0 ;
38  (list.centinelItem)->_prevItem = (list.centinelItem)->_nextItem = list.centinelItem ;
39  return list ;
40 }
41 
46 void
47 CNDestroyList(struct CNList * dst) ;
48 
54 static inline size_t
55 CNCountOfItemsInList(const struct CNList * src)
56 {
57  return src->itemCount ;
58 }
59 
65 static inline struct CNListItem *
66 CNFirstListItem(const struct CNList * src)
67 {
68  return (src->centinelItem)->_nextItem ;
69 }
70 
76 static inline struct CNListItem *
77 CNLastListItem(const struct CNList * src)
78 {
79  return (src->centinelItem)->_prevItem ;
80 }
81 
87 static inline struct CNListItem *
88 CNCentinelListItem(const struct CNList * src)
89 {
90  return src->centinelItem ;
91 }
92 
98 void
99 CNAppendItemToList(struct CNList * dst, void * src) ;
100 
106 void
107 CNPrependItemToList(struct CNList * dst, void * src) ;
108 
114 struct CNList
115 CNCopyList(const struct CNList * src) ;
116 
124 void
125 CNInsertItemToList(struct CNList * owner, struct CNListItem * prev, void * src) ;
126 
134 void
135 CNInsertItemsToList(struct CNList * owner, struct CNListItem * prev, const struct CNList * src) ;
136 
143 void *
144 CNUnlinkItemFromList(struct CNList * owner, struct CNListItem * dst) ;
145 
153 void *
154 CNUnlinkFirstItemFromList(struct CNList * dst) ;
155 
163 void *
164 CNUnlinkLastItemFromList(struct CNList * dst) ;
165 
171 void
172 CNMoveList(struct CNList * dst, struct CNList * src) ;
173 
179 void
180 CNAppendItemsToList(struct CNList * dst, struct CNList * src) ;
181 
189 struct CNListItem *
190 CNSearchDataInList(const struct CNList * list, void * data) ;
191 
200 struct CNListItem *
201 CNSearchMatchedDataInList(const struct CNList * list, CNMatchDataFuncRef func, void * info) ;
202 
203 #endif /* CNLIST_H */
Single linked list item.
Definition: CNListItem.h:16
struct CNListItem * CNSearchDataInList(const struct CNList *list, void *data)
Search list item which has source data reference.
void * CNUnlinkLastItemFromList(struct CNList *dst)
Get and unlink last item in the list.
static struct CNList CNMakeEmptyList(struct CNResource *resource)
Initialize CNList.
Definition: CNList.h:32
List of pointers.
Definition: CNList.h:17
static struct CNListItem * CNCentinelListItem(const struct CNList *src)
Get centinel item of the list.
Definition: CNList.h:88
void * CNUnlinkItemFromList(struct CNList *owner, struct CNListItem *dst)
Unlink an item from the list and return it's data.
struct CNListItem * _nextItem
Definition: CNListItem.h:18
void * CNUnlinkFirstItemFromList(struct CNList *dst)
Get and unlink 1st item in the list.
void CNAppendItemToList(struct CNList *dst, void *src)
Append object to the list.
static struct CNListItem * CNLastListItem(const struct CNList *src)
Get last item in the list.
Definition: CNList.h:77
void CNMoveList(struct CNList *dst, struct CNList *src)
Move items from source to destination.
void CNInsertItemToList(struct CNList *owner, struct CNListItem *prev, void *src)
Insert item to the list.
struct CNListItem * CNSearchMatchedDataInList(const struct CNList *list, CNMatchDataFuncRef func, void *info)
Search list item which matched source data.
void CNPrependItemToList(struct CNList *dst, void *src)
Prepend object to the list.
struct CNResource * resource
Definition: CNList.h:19
void CNDestroyList(struct CNList *dst)
Destroy CNObject(s) in the list and list items.
struct CNList CNCopyList(const struct CNList *src)
Make the copy of source list.
CNBoolean(* CNMatchDataFuncRef)(const void *src, void *info)
Function to maching objects.
Definition: CNType.h:25
Define primitive data types.
struct CNListItem * centinelItem
Root list item.
Definition: CNList.h:23
void CNInsertItemsToList(struct CNList *owner, struct CNListItem *prev, const struct CNList *src)
Insert items to the list.
struct CNListItem * _prevItem
Definition: CNListItem.h:20
static size_t CNCountOfItemsInList(const struct CNList *src)
Get count of items in the list.
Definition: CNList.h:55
Define CNListItem data structure.
static struct CNListItem * CNFirstListItem(const struct CNList *src)
Get 1st item in the list.
Definition: CNList.h:66
static struct CNListItem * CNAllocateListItem(void *data, struct CNResource *resource)
Allocate CNListItem.
Definition: CNListItem.h:34
void CNAppendItemsToList(struct CNList *dst, struct CNList *src)
Copy items from source to destination.
size_t itemCount
Definition: CNList.h:21