| 183 const struct cx_iterator_s *iter = it; |
183 const struct cx_iterator_s *iter = it; |
| 184 void **ptr = iter->base.current_impl(it); |
184 void **ptr = iter->base.current_impl(it); |
| 185 return ptr == NULL ? NULL : *ptr; |
185 return ptr == NULL ? NULL : *ptr; |
| 186 } |
186 } |
| 187 |
187 |
| |
188 static int cx_pl_change_capacity(struct cx_list_s *list, size_t cap) { |
| |
189 if (list->climpl->change_capacity == NULL) { |
| |
190 return 0; |
| |
191 } else { |
| |
192 return list->climpl->change_capacity(list, cap); |
| |
193 } |
| |
194 } |
| |
195 |
| 188 static struct cx_iterator_s cx_pl_iterator( |
196 static struct cx_iterator_s cx_pl_iterator( |
| 189 const struct cx_list_s *list, |
197 const struct cx_list_s *list, |
| 190 size_t index, |
198 size_t index, |
| 191 bool backwards |
199 bool backwards |
| 192 ) { |
200 ) { |
| 1018 bool dst_was_empty = cxCollectionSize(dst) == 0; |
1028 bool dst_was_empty = cxCollectionSize(dst) == 0; |
| 1019 |
1029 |
| 1020 CxIterator src_iter = cxListIterator(src); |
1030 CxIterator src_iter = cxListIterator(src); |
| 1021 CxIterator other_iter = cxListIterator(other); |
1031 CxIterator other_iter = cxListIterator(other); |
| 1022 while (cxIteratorValid(src_iter) || cxIteratorValid(other_iter)) { |
1032 while (cxIteratorValid(src_iter) || cxIteratorValid(other_iter)) { |
| 1023 void *src_elem, *other_elem; |
1033 void *src_elem = NULL, *other_elem = NULL; |
| 1024 int d; |
1034 int d; |
| 1025 if (!cxIteratorValid(src_iter)) { |
1035 if (!cxIteratorValid(src_iter)) { |
| 1026 other_elem = cxIteratorCurrent(other_iter); |
1036 other_elem = cxIteratorCurrent(other_iter); |
| 1027 d = 1; |
1037 d = 1; |
| 1028 } else if (!cxIteratorValid(other_iter)) { |
1038 } else if (!cxIteratorValid(other_iter)) { |
| 1100 } |
1110 } |
| 1101 |
1111 |
| 1102 int cxListUnionSimple(CxList *dst, const CxList *src, const CxList *other) { |
1112 int cxListUnionSimple(CxList *dst, const CxList *src, const CxList *other) { |
| 1103 return cxListUnion(dst, src, other, use_simple_clone_func(src)); |
1113 return cxListUnion(dst, src, other, use_simple_clone_func(src)); |
| 1104 } |
1114 } |
| |
1115 |
| |
1116 int cxListReserve(CxList *list, size_t capacity) { |
| |
1117 if (list->cl->change_capacity == NULL) { |
| |
1118 return 0; |
| |
1119 } |
| |
1120 if (capacity <= cxCollectionSize(list)) { |
| |
1121 return 0; |
| |
1122 } |
| |
1123 return list->cl->change_capacity(list, capacity); |
| |
1124 } |
| |
1125 |
| |
1126 int cxListShrink(CxList *list) { |
| |
1127 if (list->cl->change_capacity == NULL) { |
| |
1128 return 0; |
| |
1129 } |
| |
1130 return list->cl->change_capacity(list, cxCollectionSize(list)); |
| |
1131 } |