454 * @param list the list |
455 * @param list the list |
455 * @param index the index where the iterator shall point at |
456 * @param index the index where the iterator shall point at |
456 * @return a new iterator |
457 * @return a new iterator |
457 */ |
458 */ |
458 __attribute__((__nonnull__, __warn_unused_result__)) |
459 __attribute__((__nonnull__, __warn_unused_result__)) |
459 static inline CxIterator cxListIterator( |
460 static inline CxIterator cxListIteratorAt( |
460 CxList const *list, |
461 CxList const *list, |
461 size_t index |
462 size_t index |
462 ) { |
463 ) { |
463 return list->cl->iterator(list, index); |
464 return list->cl->iterator(list, index, false); |
|
465 } |
|
466 |
|
467 /** |
|
468 * Returns a backwards iterator pointing to the item at the specified index. |
|
469 * |
|
470 * The returned iterator is position-aware. |
|
471 * |
|
472 * If the index is out of range, a past-the-end iterator will be returned. |
|
473 * |
|
474 * @param list the list |
|
475 * @param index the index where the iterator shall point at |
|
476 * @return a new iterator |
|
477 */ |
|
478 __attribute__((__nonnull__, __warn_unused_result__)) |
|
479 static inline CxIterator cxListBackwardsIteratorAt( |
|
480 CxList const *list, |
|
481 size_t index |
|
482 ) { |
|
483 return list->cl->iterator(list, index, true); |
464 } |
484 } |
465 |
485 |
466 /** |
486 /** |
467 * Returns a mutating iterator pointing to the item at the specified index. |
487 * Returns a mutating iterator pointing to the item at the specified index. |
468 * |
488 * |
473 * @param list the list |
493 * @param list the list |
474 * @param index the index where the iterator shall point at |
494 * @param index the index where the iterator shall point at |
475 * @return a new iterator |
495 * @return a new iterator |
476 */ |
496 */ |
477 __attribute__((__nonnull__, __warn_unused_result__)) |
497 __attribute__((__nonnull__, __warn_unused_result__)) |
478 CxMutIterator cxListMutIterator( |
498 CxMutIterator cxListMutIteratorAt( |
479 CxList *list, |
499 CxList *list, |
480 size_t index |
500 size_t index |
481 ); |
501 ); |
482 |
502 |
483 /** |
503 /** |
|
504 * Returns a mutating backwards iterator pointing to the item at the |
|
505 * specified index. |
|
506 * |
|
507 * The returned iterator is position-aware. |
|
508 * |
|
509 * If the index is out of range, a past-the-end iterator will be returned. |
|
510 * |
|
511 * @param list the list |
|
512 * @param index the index where the iterator shall point at |
|
513 * @return a new iterator |
|
514 */ |
|
515 __attribute__((__nonnull__, __warn_unused_result__)) |
|
516 CxMutIterator cxListMutBackwardsIteratorAt( |
|
517 CxList *list, |
|
518 size_t index |
|
519 ); |
|
520 |
|
521 /** |
484 * Returns an iterator pointing to the first item of the list. |
522 * Returns an iterator pointing to the first item of the list. |
485 * |
523 * |
486 * The returned iterator is position-aware. |
524 * The returned iterator is position-aware. |
487 * |
525 * |
488 * If the list is empty, a past-the-end iterator will be returned. |
526 * If the list is empty, a past-the-end iterator will be returned. |
489 * |
527 * |
490 * @param list the list |
528 * @param list the list |
491 * @return a new iterator |
529 * @return a new iterator |
492 */ |
530 */ |
493 __attribute__((__nonnull__, __warn_unused_result__)) |
531 __attribute__((__nonnull__, __warn_unused_result__)) |
494 static inline CxIterator cxListBegin(CxList const *list) { |
532 static inline CxIterator cxListIterator(CxList const *list) { |
495 return list->cl->iterator(list, 0); |
533 return list->cl->iterator(list, 0, false); |
496 } |
534 } |
497 |
535 |
498 /** |
536 /** |
499 * Returns a mutating iterator pointing to the first item of the list. |
537 * Returns a mutating iterator pointing to the first item of the list. |
500 * |
538 * |
504 * |
542 * |
505 * @param list the list |
543 * @param list the list |
506 * @return a new iterator |
544 * @return a new iterator |
507 */ |
545 */ |
508 __attribute__((__nonnull__, __warn_unused_result__)) |
546 __attribute__((__nonnull__, __warn_unused_result__)) |
509 static inline CxMutIterator cxListBeginMut(CxList *list) { |
547 static inline CxMutIterator cxListMutIterator(CxList *list) { |
510 return cxListMutIterator(list, 0); |
548 return cxListMutIteratorAt(list, 0); |
|
549 } |
|
550 |
|
551 |
|
552 /** |
|
553 * Returns a backwards iterator pointing to the last item of the list. |
|
554 * |
|
555 * The returned iterator is position-aware. |
|
556 * |
|
557 * If the list is empty, a past-the-end iterator will be returned. |
|
558 * |
|
559 * @param list the list |
|
560 * @return a new iterator |
|
561 */ |
|
562 __attribute__((__nonnull__, __warn_unused_result__)) |
|
563 static inline CxIterator cxListBackwardsIterator(CxList const *list) { |
|
564 return list->cl->iterator(list, list->size - 1, true); |
|
565 } |
|
566 |
|
567 /** |
|
568 * Returns a mutating backwards iterator pointing to the last item of the list. |
|
569 * |
|
570 * The returned iterator is position-aware. |
|
571 * |
|
572 * If the list is empty, a past-the-end iterator will be returned. |
|
573 * |
|
574 * @param list the list |
|
575 * @return a new iterator |
|
576 */ |
|
577 __attribute__((__nonnull__, __warn_unused_result__)) |
|
578 static inline CxMutIterator cxListMutBackwardsIterator(CxList *list) { |
|
579 return cxListMutBackwardsIteratorAt(list, list->size - 1); |
511 } |
580 } |
512 |
581 |
513 /** |
582 /** |
514 * Returns the index of the first element that equals \p elem. |
583 * Returns the index of the first element that equals \p elem. |
515 * |
584 * |