src/cx/list.h

changeset 854
fe0d69d72bcd
parent 853
d4baf4dd55c3
child 856
6bbbf219251d
equal deleted inserted replaced
853:d4baf4dd55c3 854:fe0d69d72bcd
50 50
51 /** 51 /**
52 * Structure for holding the base data of a list. 52 * Structure for holding the base data of a list.
53 */ 53 */
54 struct cx_list_s { 54 struct cx_list_s {
55 CX_COLLECTION_MEMBERS 55 CX_COLLECTION_BASE;
56 /** 56 /**
57 * The list class definition. 57 * The list class definition.
58 */ 58 */
59 cx_list_class const *cl; 59 cx_list_class const *cl;
60 /** 60 /**
211 * @return true, if this list is storing pointers 211 * @return true, if this list is storing pointers
212 * @see cxListStorePointers() 212 * @see cxListStorePointers()
213 */ 213 */
214 __attribute__((__nonnull__)) 214 __attribute__((__nonnull__))
215 static inline bool cxListIsStoringPointers(CxList const *list) { 215 static inline bool cxListIsStoringPointers(CxList const *list) {
216 return list->store_pointer; 216 return list->base.store_pointer;
217 } 217 }
218 218
219 /** 219 /**
220 * Returns the number of elements currently stored in the list. 220 * Returns the number of elements currently stored in the list.
221 * 221 *
222 * @param list the list 222 * @param list the list
223 * @return the number of currently stored elements 223 * @return the number of currently stored elements
224 */ 224 */
225 __attribute__((__nonnull__)) 225 __attribute__((__nonnull__))
226 static inline size_t cxListSize(CxList const *list) { 226 static inline size_t cxListSize(CxList const *list) {
227 return list->size; 227 return list->base.size;
228 } 228 }
229 229
230 /** 230 /**
231 * Adds an item to the end of the list. 231 * Adds an item to the end of the list.
232 * 232 *
238 __attribute__((__nonnull__)) 238 __attribute__((__nonnull__))
239 static inline int cxListAdd( 239 static inline int cxListAdd(
240 CxList *list, 240 CxList *list,
241 void const *elem 241 void const *elem
242 ) { 242 ) {
243 return list->cl->insert_element(list, list->size, elem); 243 return list->cl->insert_element(list, list->base.size, elem);
244 } 244 }
245 245
246 /** 246 /**
247 * Adds multiple items to the end of the list. 247 * Adds multiple items to the end of the list.
248 * 248 *
263 static inline size_t cxListAddArray( 263 static inline size_t cxListAddArray(
264 CxList *list, 264 CxList *list,
265 void const *array, 265 void const *array,
266 size_t n 266 size_t n
267 ) { 267 ) {
268 return list->cl->insert_array(list, list->size, array, n); 268 return list->cl->insert_array(list, list->base.size, array, n);
269 } 269 }
270 270
271 /** 271 /**
272 * Inserts an item at the specified index. 272 * Inserts an item at the specified index.
273 * 273 *
545 * @param list the list 545 * @param list the list
546 * @return a new iterator 546 * @return a new iterator
547 */ 547 */
548 __attribute__((__nonnull__, __warn_unused_result__)) 548 __attribute__((__nonnull__, __warn_unused_result__))
549 static inline CxIterator cxListBackwardsIterator(CxList const *list) { 549 static inline CxIterator cxListBackwardsIterator(CxList const *list) {
550 return list->cl->iterator(list, list->size - 1, true); 550 return list->cl->iterator(list, list->base.size - 1, true);
551 } 551 }
552 552
553 /** 553 /**
554 * Returns a mutating backwards iterator pointing to the last item of the list. 554 * Returns a mutating backwards iterator pointing to the last item of the list.
555 * 555 *
560 * @param list the list 560 * @param list the list
561 * @return a new iterator 561 * @return a new iterator
562 */ 562 */
563 __attribute__((__nonnull__, __warn_unused_result__)) 563 __attribute__((__nonnull__, __warn_unused_result__))
564 static inline CxIterator cxListMutBackwardsIterator(CxList *list) { 564 static inline CxIterator cxListMutBackwardsIterator(CxList *list) {
565 return cxListMutBackwardsIteratorAt(list, list->size - 1); 565 return cxListMutBackwardsIteratorAt(list, list->base.size - 1);
566 } 566 }
567 567
568 /** 568 /**
569 * Returns the index of the first element that equals \p elem. 569 * Returns the index of the first element that equals \p elem.
570 * 570 *

mercurial