1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 #ifndef UCX_LIST_H
37 #define UCX_LIST_H
38
39 #include "common.h"
40 #include "collection.h"
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46
47
48
49 typedef struct cx_list_class_s cx_list_class;
50
51
52
53
54 struct cx_list_s {
55
56
57
58 CX_COLLECTION_BASE;
59
60
61
62 const cx_list_class *cl;
63
64
65
66 const cx_list_class *climpl;
67 };
68
69
70
71
72 struct cx_list_class_s {
73
74
75
76
77
78
79 void (*deallocate)(
struct cx_list_s *list);
80
81
82
83
84
85
86 void *(*insert_element)(
struct cx_list_s *list,
size_t index,
const void *data);
87
88
89
90
91
92
93
94
95
96 size_t (*insert_array)(
struct cx_list_s *list,
size_t index,
const void *data,
size_t n);
97
98
99
100
101
102
103
104 size_t (*insert_sorted)(
struct cx_list_s *list,
const void *sorted_data,
size_t n);
105
106
107
108
109
110
111
112 size_t (*insert_unique)(
struct cx_list_s *list,
const void *sorted_data,
size_t n);
113
114
115
116
117 int (*insert_iter)(
struct cx_iterator_s *iter,
const void *elem,
int prepend);
118
119
120
121
122
123
124
125
126
127
128
129 size_t (*remove)(
struct cx_list_s *list,
size_t index,
size_t num,
void *targetbuf);
130
131
132
133
134 void (*clear)(
struct cx_list_s *list);
135
136
137
138
139
140
141 int (*swap)(
struct cx_list_s *list,
size_t i,
size_t j);
142
143
144
145
146 void *(*at)(
const struct cx_list_s *list,
size_t index);
147
148
149
150
151 size_t (*find_remove)(
struct cx_list_s *list,
const void *elem, bool remove);
152
153
154
155
156
157
158 void (*sort)(
struct cx_list_s *list);
159
160
161
162
163
164
165 int (*compare)(
const struct cx_list_s *list,
const struct cx_list_s *other);
166
167
168
169
170 void (*reverse)(
struct cx_list_s *list);
171
172
173
174
175
176 int (*change_capacity)(
struct cx_list_s *list,
size_t new_capacity);
177
178
179
180
181 struct cx_iterator_s (*iterator)(
const struct cx_list_s *list,
size_t index, bool backward);
182 };
183
184
185
186
187 typedef struct cx_list_s CxList;
188
189
190
191
192
193
194
195
196
197 CX_EXPORT extern CxList *
const cxEmptyList;
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213 cx_attr_nonnull
214 CX_EXPORT size_t cx_list_default_insert_array(
struct cx_list_s *list,
215 size_t index,
const void *data,
size_t n);
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233 cx_attr_nonnull
234 CX_EXPORT size_t cx_list_default_insert_sorted(
struct cx_list_s *list,
235 const void *sorted_data,
size_t n);
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253 cx_attr_nonnull
254 CX_EXPORT size_t cx_list_default_insert_unique(
struct cx_list_s *list,
255 const void *sorted_data,
size_t n);
256
257
258
259
260
261
262
263
264
265
266
267
268 cx_attr_nonnull
269 CX_EXPORT void cx_list_default_sort(
struct cx_list_s *list);
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284 cx_attr_nonnull
285 CX_EXPORT int cx_list_default_swap(
struct cx_list_s *list,
size_t i,
size_t j);
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331 cx_attr_nonnull_arg(
1,
2,
3)
332 CX_EXPORT void cx_list_init(
struct cx_list_s *list,
333 struct cx_list_class_s *cl,
const struct cx_allocator_s *allocator,
334 cx_compare_func comparator,
size_t elem_size);
335
336
337
338
339
340
341
342 cx_attr_nonnull
343 CX_EXPORT size_t cxListSize(
const CxList *list);
344
345
346
347
348
349
350
351
352
353
354
355 cx_attr_nonnull
356 CX_EXPORT int cxListAdd(CxList *list,
const void *elem);
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375 cx_attr_nonnull
376 CX_EXPORT size_t cxListAddArray(CxList *list,
const void *array,
size_t n);
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392 cx_attr_nonnull
393 CX_EXPORT int cxListInsert(CxList *list,
size_t index,
const void *elem);
394
395
396
397
398
399
400
401
402
403
404
405
406
407 cx_attr_nonnull
408 CX_EXPORT void *cxListEmplaceAt(CxList *list,
size_t index);
409
410
411
412
413
414
415
416
417
418
419
420 cx_attr_nonnull
421 CX_EXPORT void *cxListEmplace(CxList *list);
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440 cx_attr_nonnull
441 CX_EXPORT CxIterator cxListEmplaceArrayAt(CxList *list,
size_t index,
size_t n);
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459 cx_attr_nonnull
460 CX_EXPORT CxIterator cxListEmplaceArray(CxList *list,
size_t n);
461
462
463
464
465
466
467
468
469
470
471
472 cx_attr_nonnull
473 CX_EXPORT int cxListInsertSorted(CxList *list,
const void *elem);
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488 cx_attr_nonnull
489 CX_EXPORT int cxListInsertUnique(CxList *list,
const void *elem);
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511 cx_attr_nonnull
512 CX_EXPORT size_t cxListInsertArray(CxList *list,
size_t index,
const void *array,
size_t n);
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533 cx_attr_nonnull
534 CX_EXPORT size_t cxListInsertSortedArray(CxList *list,
const void *array,
size_t n);
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568 cx_attr_nonnull
569 CX_EXPORT size_t cxListInsertUniqueArray(CxList *list,
const void *array,
size_t n);
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587 cx_attr_nonnull
588 CX_EXPORT int cxListInsertAfter(CxIterator *iter,
const void *elem);
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606 cx_attr_nonnull
607 CX_EXPORT int cxListInsertBefore(CxIterator *iter,
const void *elem);
608
609
610
611
612
613
614
615
616
617
618
619
620 cx_attr_nonnull
621 CX_EXPORT int cxListRemove(CxList *list,
size_t index);
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636 cx_attr_nonnull cx_attr_access_w(
3)
637 CX_EXPORT int cxListRemoveAndGet(CxList *list,
size_t index,
void *targetbuf);
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653 cx_attr_nonnull cx_attr_access_w(
2)
654 CX_EXPORT int cxListRemoveAndGetFirst(CxList *list,
void *targetbuf);
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672 #define cxListPopFront(list, targetbuf) cxListRemoveAndGetFirst((list), (targetbuf))
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687 cx_attr_nonnull cx_attr_access_w(
2)
688 CX_EXPORT int cxListRemoveAndGetLast(CxList *list,
void *targetbuf);
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706 #define cxListPop(list, targetbuf) cxListRemoveAndGetLast((list), (targetbuf))
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723 cx_attr_nonnull
724 CX_EXPORT size_t cxListRemoveArray(CxList *list,
size_t index,
size_t num);
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739 cx_attr_nonnull cx_attr_access_w(
4)
740 CX_EXPORT size_t cxListRemoveArrayAndGet(CxList *list,
size_t index,
size_t num,
void *targetbuf);
741
742
743
744
745
746
747
748
749
750 cx_attr_nonnull
751 CX_EXPORT void cxListClear(CxList *list);
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766 cx_attr_nonnull
767 CX_EXPORT int cxListSwap(CxList *list,
size_t i,
size_t j);
768
769
770
771
772
773
774
775
776
777
778 cx_attr_nonnull
779 CX_EXPORT void *cxListAt(
const CxList *list,
size_t index);
780
781
782
783
784
785
786
787
788
789 cx_attr_nonnull
790 CX_EXPORT void *cxListFirst(
const CxList *list);
791
792
793
794
795
796
797
798
799
800 cx_attr_nonnull
801 CX_EXPORT void *cxListLast(
const CxList *list);
802
803
804
805
806
807
808
809
810
811
812
813
814
815 cx_attr_nonnull
816 CX_EXPORT int cxListSet(CxList *list,
size_t index,
const void *elem);
817
818
819
820
821
822
823
824
825
826
827
828
829 cx_attr_nodiscard
830 CX_EXPORT CxIterator cxListIteratorAt(
const CxList *list,
size_t index);
831
832
833
834
835
836
837
838
839
840
841
842
843 cx_attr_nodiscard
844 CX_EXPORT CxIterator cxListBackwardsIteratorAt(
const CxList *list,
size_t index);
845
846
847
848
849
850
851
852
853
854
855
856 cx_attr_nodiscard
857 CX_EXPORT CxIterator cxListIterator(
const CxList *list);
858
859
860
861
862
863
864
865
866
867
868
869 cx_attr_nodiscard
870 CX_EXPORT CxIterator cxListBackwardsIterator(
const CxList *list);
871
872
873
874
875
876
877
878
879
880
881
882
883 cx_attr_nonnull cx_attr_nodiscard
884 CX_EXPORT size_t cxListFind(
const CxList *list,
const void *elem);
885
886
887
888
889
890
891
892
893
894
895
896
897 cx_attr_nonnull cx_attr_nodiscard
898 CX_EXPORT bool cxListContains(
const CxList* list,
const void* elem);
899
900
901
902
903
904
905
906
907
908 cx_attr_nonnull cx_attr_nodiscard
909 CX_EXPORT bool cxListIndexValid(
const CxList *list,
size_t index);
910
911
912
913
914
915
916
917
918
919
920
921
922 cx_attr_nonnull
923 CX_EXPORT size_t cxListFindRemove(CxList *list,
const void *elem);
924
925
926
927
928
929
930
931
932 cx_attr_nonnull
933 CX_EXPORT void cxListSort(CxList *list);
934
935
936
937
938
939
940 cx_attr_nonnull
941 CX_EXPORT void cxListReverse(CxList *list);
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957 cx_attr_nonnull cx_attr_nodiscard
958 CX_EXPORT int cxListCompare(
const CxList *list,
const CxList *other);
959
960
961
962
963
964
965
966
967 CX_EXPORT void cxListFree(CxList *list);
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989 cx_attr_nonnull_arg(
1,
2,
3)
990 CX_EXPORT int cxListClone(CxList *dst,
const CxList *src,
991 cx_clone_func clone_func,
const CxAllocator *clone_allocator,
void *data);
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012 cx_attr_nonnull_arg(
1,
2,
3,
4)
1013 CX_EXPORT int cxListDifference(CxList *dst,
1014 const CxList *minuend,
const CxList *subtrahend,
1015 cx_clone_func clone_func,
const CxAllocator *clone_allocator,
void *data);
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036 cx_attr_nonnull_arg(
1,
2,
3,
4)
1037 CX_EXPORT int cxListIntersection(CxList *dst,
const CxList *src,
const CxList *other,
1038 cx_clone_func clone_func,
const CxAllocator *clone_allocator,
void *data);
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061 cx_attr_nonnull_arg(
1,
2,
3,
4)
1062 CX_EXPORT int cxListUnion(CxList *dst,
const CxList *src,
const CxList *other,
1063 cx_clone_func clone_func,
const CxAllocator *clone_allocator,
void *data);
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084 cx_attr_nonnull
1085 CX_EXPORT int cxListCloneSimple(CxList *dst,
const CxList *src);
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106 cx_attr_nonnull
1107 CX_EXPORT int cxListDifferenceSimple(CxList *dst,
1108 const CxList *minuend,
const CxList *subtrahend);
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129 cx_attr_nonnull
1130 CX_EXPORT int cxListIntersectionSimple(CxList *dst,
const CxList *src,
const CxList *other);
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153 cx_attr_nonnull
1154 CX_EXPORT int cxListUnionSimple(CxList *dst,
const CxList *src,
const CxList *other);
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173 cx_attr_nonnull
1174 CX_EXPORT int cxListReserve(CxList *list,
size_t capacity);
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187 cx_attr_nonnull
1188 CX_EXPORT int cxListShrink(CxList *list);
1189
1190 #ifdef __cplusplus
1191 }
1192 #endif
1193
1194 #endif
1195