287 * @see cxListInsert() |
295 * @see cxListInsert() |
288 * @see cxListInsertBefore() |
296 * @see cxListInsertBefore() |
289 */ |
297 */ |
290 __attribute__((__nonnull__)) |
298 __attribute__((__nonnull__)) |
291 static inline int cxListInsertAfter( |
299 static inline int cxListInsertAfter( |
292 CxIterator *iter, |
300 CxMutIterator *iter, |
293 void const *elem |
301 void const *elem |
294 ) { |
302 ) { |
295 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 0); |
303 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 0); |
296 } |
304 } |
297 |
305 |
310 * @see cxListInsert() |
318 * @see cxListInsert() |
311 * @see cxListInsertAfter() |
319 * @see cxListInsertAfter() |
312 */ |
320 */ |
313 __attribute__((__nonnull__)) |
321 __attribute__((__nonnull__)) |
314 static inline int cxListInsertBefore( |
322 static inline int cxListInsertBefore( |
315 CxIterator *iter, |
323 CxMutIterator *iter, |
316 void const *elem |
324 void const *elem |
317 ) { |
325 ) { |
318 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 1); |
326 return ((struct cx_list_s *) iter->src_handle)->cl->insert_iter(iter, elem, 1); |
319 } |
327 } |
320 |
328 |
358 * @param index the index where the iterator shall point at |
366 * @param index the index where the iterator shall point at |
359 * @return a new iterator |
367 * @return a new iterator |
360 */ |
368 */ |
361 __attribute__((__nonnull__, __warn_unused_result__)) |
369 __attribute__((__nonnull__, __warn_unused_result__)) |
362 static inline CxIterator cxListIterator( |
370 static inline CxIterator cxListIterator( |
363 CxList *list, |
371 CxList const *list, |
364 size_t index |
372 size_t index |
365 ) { |
373 ) { |
366 return list->cl->iterator(list, index); |
374 return list->cl->iterator(list, index); |
367 } |
375 } |
368 |
376 |
369 /** |
377 /** |
|
378 * Returns a mutating iterator pointing to the item at the specified index. |
|
379 * |
|
380 * The returned iterator is position-aware. |
|
381 * |
|
382 * If the index is out of range, a past-the-end iterator will be returned. |
|
383 * |
|
384 * @param list the list |
|
385 * @param index the index where the iterator shall point at |
|
386 * @return a new iterator |
|
387 */ |
|
388 __attribute__((__nonnull__, __warn_unused_result__)) |
|
389 static inline CxMutIterator cxListMutIterator( |
|
390 CxList *list, |
|
391 size_t index |
|
392 ) { |
|
393 return list->cl->mut_iterator(list, index); |
|
394 } |
|
395 |
|
396 /** |
370 * Returns an iterator pointing to the first item of the list. |
397 * Returns an iterator pointing to the first item of the list. |
371 * |
398 * |
372 * The returned iterator is position-aware. |
399 * The returned iterator is position-aware. |
373 * |
400 * |
374 * If the list is empty, a past-the-end iterator will be returned. |
401 * If the list is empty, a past-the-end iterator will be returned. |
375 * |
402 * |
376 * @param list the list |
403 * @param list the list |
377 * @return a new iterator |
404 * @return a new iterator |
378 */ |
405 */ |
379 __attribute__((__nonnull__, __warn_unused_result__)) |
406 __attribute__((__nonnull__, __warn_unused_result__)) |
380 static inline CxIterator cxListBegin(CxList *list) { |
407 static inline CxIterator cxListBegin(CxList const *list) { |
381 return list->cl->iterator(list, 0); |
408 return list->cl->iterator(list, 0); |
|
409 } |
|
410 |
|
411 /** |
|
412 * Returns a mutating iterator pointing to the first item of the list. |
|
413 * |
|
414 * The returned iterator is position-aware. |
|
415 * |
|
416 * If the list is empty, a past-the-end iterator will be returned. |
|
417 * |
|
418 * @param list the list |
|
419 * @return a new iterator |
|
420 */ |
|
421 __attribute__((__nonnull__, __warn_unused_result__)) |
|
422 static inline CxMutIterator cxListBeginMut(CxList *list) { |
|
423 return list->cl->mut_iterator(list, 0); |
382 } |
424 } |
383 |
425 |
384 /** |
426 /** |
385 * Returns the index of the first element that equals \p elem. |
427 * Returns the index of the first element that equals \p elem. |
386 * |
428 * |