src/list.c

changeset 1429
6e0c3a8a914a
parent 1428
0ac4aa1737fd
equal deleted inserted replaced
1428:0ac4aa1737fd 1429:6e0c3a8a914a
113 static int cx_pl_insert_iter( 113 static int cx_pl_insert_iter(
114 struct cx_iterator_s *iter, 114 struct cx_iterator_s *iter,
115 const void *elem, 115 const void *elem,
116 int prepend 116 int prepend
117 ) { 117 ) {
118 struct cx_list_s *list = iter->src_handle.m; 118 struct cx_list_s *list = iter->src_handle;
119 return list->climpl->insert_iter(iter, &elem, prepend); 119 return list->climpl->insert_iter(iter, &elem, prepend);
120 } 120 }
121 121
122 static size_t cx_pl_remove( 122 static size_t cx_pl_remove(
123 struct cx_list_s *list, 123 struct cx_list_s *list,
244 const struct cx_list_s *list, 244 const struct cx_list_s *list,
245 size_t index, 245 size_t index,
246 cx_attr_unused bool backwards 246 cx_attr_unused bool backwards
247 ) { 247 ) {
248 CxIterator iter = {0}; 248 CxIterator iter = {0};
249 iter.src_handle.c = list; 249 iter.src_handle = (void*) list;
250 iter.index = index; 250 iter.index = index;
251 iter.base.valid = cx_emptyl_iter_valid; 251 iter.base.valid = cx_emptyl_iter_valid;
252 return iter; 252 return iter;
253 } 253 }
254 254
648 return n; 648 return n;
649 } 649 }
650 } 650 }
651 651
652 int cxListInsertAfter(CxIterator *iter, const void *elem) { 652 int cxListInsertAfter(CxIterator *iter, const void *elem) {
653 CxList* list = (CxList*)iter->src_handle.m; 653 CxList* list = (CxList*)iter->src_handle;
654 list->collection.sorted = false; 654 list->collection.sorted = false;
655 return list->cl->insert_iter(iter, elem, 0); 655 return list->cl->insert_iter(iter, elem, 0);
656 } 656 }
657 657
658 int cxListInsertBefore(CxIterator *iter, const void *elem) { 658 int cxListInsertBefore(CxIterator *iter, const void *elem) {
659 CxList* list = (CxList*)iter->src_handle.m; 659 CxList* list = (CxList*)iter->src_handle;
660 list->collection.sorted = false; 660 list->collection.sorted = false;
661 return list->cl->insert_iter(iter, elem, 1); 661 return list->cl->insert_iter(iter, elem, 1);
662 } 662 }
663 663
664 int cxListRemove(CxList *list, size_t index) { 664 int cxListRemove(CxList *list, size_t index) {
733 CxIterator cxListBackwardsIteratorAt(const CxList *list, size_t index) { 733 CxIterator cxListBackwardsIteratorAt(const CxList *list, size_t index) {
734 if (list == NULL) list = cxEmptyList; 734 if (list == NULL) list = cxEmptyList;
735 return list->cl->iterator(list, index, true); 735 return list->cl->iterator(list, index, true);
736 } 736 }
737 737
738 CxIterator cxListMutIteratorAt(CxList *list, size_t index) {
739 if (list == NULL) list = cxEmptyList;
740 CxIterator it = list->cl->iterator(list, index, false);
741 it.base.mutating = true;
742 return it;
743 }
744
745 CxIterator cxListMutBackwardsIteratorAt(CxList *list, size_t index) {
746 if (list == NULL) list = cxEmptyList;
747 CxIterator it = list->cl->iterator(list, index, true);
748 it.base.mutating = true;
749 return it;
750 }
751
752 CxIterator cxListIterator(const CxList *list) { 738 CxIterator cxListIterator(const CxList *list) {
753 if (list == NULL) list = cxEmptyList; 739 if (list == NULL) list = cxEmptyList;
754 return list->cl->iterator(list, 0, false); 740 return list->cl->iterator(list, 0, false);
755 } 741 }
756 742
757 CxIterator cxListMutIterator(CxList *list) {
758 if (list == NULL) list = cxEmptyList;
759 return cxListMutIteratorAt(list, 0);
760 }
761
762 CxIterator cxListBackwardsIterator(const CxList *list) { 743 CxIterator cxListBackwardsIterator(const CxList *list) {
763 if (list == NULL) list = cxEmptyList; 744 if (list == NULL) list = cxEmptyList;
764 return list->cl->iterator(list, list->collection.size - 1, true); 745 return list->cl->iterator(list, list->collection.size - 1, true);
765 }
766
767 CxIterator cxListMutBackwardsIterator(CxList *list) {
768 if (list == NULL) list = cxEmptyList;
769 return cxListMutBackwardsIteratorAt(list, list->collection.size - 1);
770 } 746 }
771 747
772 size_t cxListFind(const CxList *list, const void *elem) { 748 size_t cxListFind(const CxList *list, const void *elem) {
773 return list->cl->find_remove((CxList*)list, elem, false); 749 return list->cl->find_remove((CxList*)list, elem, false);
774 } 750 }

mercurial