aboutsummaryrefslogtreecommitdiffstats
path: root/libparc/parc/algol/parc_List.h
blob: 6c17453cc86dc95e54c2b6c2e71d394505b03361 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
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
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
/*
 * Copyright (c) 2017 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


/**
 * @file parc_List.h
 * @ingroup datastructures
 * @brief PARC (Generic) List
 *
 * An ordered collection (also known as a sequence).
 * The user of this interface has precise control over where in the list each element is inserted.
 * The user can access elements by their integer index (position in the list), and search for elements in the list.
 * Unlike sets, lists typically allow duplicate elements.
 * More formally, lists typically allow pairs of elements e1 and e2 such that e1.equals(e2), and they typically allow
 * multiple null elements if they allow null elements at all.
 * It is not inconceivable that someone might wish to implement a list that prohibits duplicates,
 * by throwing runtime exceptions when the user attempts to insert them, but we expect this usage to be rare.
 *
 */
#ifndef libparc_parc_List_h
#define libparc_parc_List_h

#include <stdbool.h>

struct parc_list;
/**
 * @typedef PARCList
 * @brief  An ordered collection (also known as a sequence).
 */
typedef struct parc_list PARCList;

#include <parc/algol/parc_HashCode.h>

#include <parc/algol/parc_Collection.h>
#include <parc/algol/parc_Object.h>

/**
 * @typedef PARCListInterface
 * @brief The interface of a `PARCList` including functions such as copy, destroy, add, etc.
 */
typedef struct parc_list_interface {
    /**
     * Copy an instance of `PARCList`
     *
     * @param [in] original An instance of `PARCList` to copy
     *
     * @return  A pointer to the new list.
     */
    void *(*Copy)(const PARCList * original);

    /**
     * Destroy the List
     *
     * @param [in,out] instancePtr
     * @return a pointer to the destroyed List.
     */
    void (*Destroy)(void **instancePtr);

    /**
     * Tests if this list is empty.
     *
     * @param [in] instance
     * @return true if the list is empty
     */
    bool (*IsEmpty)(const void *instance);

    /**
     * Appends the specified element to the end of this list (optional operation).
     *
     * @param [in,out] The instance of `PARCList` to append the element to
     * @param [in] element The pointer to the element to be added to the `PARCList`
     * @return true if the element was added successfully.
     */
    bool (*Add)(void *instance, PARCObject *element);

    /**
     * Inserts the specified element at the specified position in this list (optional operation).
     *
     * @param [in,out] instance The instance of `PARCList` to modify
     * @param [in] index The index in `PARCList` at which to insert the @p element
     * @param [in] element The element to insert in `PARCList` at @p index.
     */
    void (*AddAtIndex)(void *instance, int index, PARCObject *element);

    /**
     * Append elements of @p collection to @p instance
     *
     *   Appends all of the elements in the specified collection to the end of this list,
     *    in the order that they are returned by the specified collection's iterator (optional operation).
     *
     * @param [in,out] instance The `PARCList` to be modified
     * @param [in] collection The collection to be added
     * @return true if add is successful.
     */
    bool (*AddCollection)(void *instance, PARCCollection *collection);

    /**
     * Inserts all of the elements in the specified collection into this list at the specified position (optional operation)
     *
     * @param [in,out] instance The `PARCList` to be modified
     * @param [in] index The position at which to insert the @p collection
     * @param [in] collection The collection to be added
     * @return true if add is successful.
     * @endcode
     */
    bool (*AddCollectionAtIndex)(void *instance, int index, PARCCollection *collection);

    /**
     * Removes all of the elements from this list (optional operation).
     *
     * @param [in,out] instance The instance of `PARCList` to empty.
     */
    void (*Clear)(void *instance);

    /**
     * Returns true if this list contains the specified element.
     *
     * @param [in] instance The instance of `PARCList` to inspect
     * @param [in] element The element to search for in @p instance
     * @return true if the @p element is found in @p instance.
     */
    bool (*Contains)(const void *instance, const PARCObject *element);

    /**
     * Returns true if this list contains all of the elements of the specified collection.
     *
     * @param [in] instance The instance of `PARCList` to inspect
     * @param [in] collection The instance of {@link PARCCollection} whose elements are sought in @p instance
     * @return true if all of the elements in @p collection is found in @p instance
     */
    bool (*ContainsCollection)(const void *instance, const PARCCollection *collection);

    /**
     * Compares the specified object with this list for equality.
     *
     * @param [in] xInstance The first `PARCList` instance to compare
     * @param [in] yInstance The second `PARCList` instance to compare
     * @return true if the two instances are equal
     */
    bool (*Equals)(const void *xInstance, const void *yInstance);

    /**
     * Returns the element at the specified position in this list.
     *
     * @param [in] instance A pointer to the instance of `PARCList`
     * @param index The index of the element to be returned
     * @return A pointer to the element at @p index
     */
    PARCObject *(*GetAtIndex)(const void *instance, size_t index);

    /**
     * Returns the hash code value for this list.
     *
     * @param [in] instance A pointer to the instance of `PARCList`
     * @return int The hash code value
     */
    PARCHashCode (*HashCode)(const void *instance);

    /**
     * Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
     *
     * @param [in] instance A pointer to the instance of `PARCList`
     * @param [in] element A pointer to the element to locate in @p instance
     * @return size_t the index of the first located @p element or -1 if not found
     */
    size_t (*IndexOf)(const void *instance, const PARCObject *element);

    /**
     * Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
     *
     * @param [in] instance A pointer to the instance of `PARCList`
     * @param [in] element A pointer to the element to locate in @p instance
     * @return size_t the index of the last located @p element or -1 if not found
     *
     * Example:
     * @code
     * <#example#>
     * @endcode
     */
    size_t (*LastIndexOf)(void *instance, const PARCObject *element);

    /**
     * Removes the element at the specified position in this list (optional operation).
     *
     * @param [in,out] instance A pointer to the instance of `PARCList` to modify
     * @param [in] index The index of the element to remove
     * @return A pointer to the removed element
     *
     * Example:
     * @code
     * <#example#>
     * @endcode
     */
    PARCObject *(*RemoveAtIndex)(PARCList * list, size_t index);

    /**
     * Removes the first occurrence of the specified element from this list, if it is present (optional operation).
     *
     * @param [in,out] instance A pointer to the instance of `PARCList` to modify
     * @param element The element to find and remove
     * @return true if element found and removed
     *
     * Example:
     * @code
     * <#example#>
     * @endcode
     */
    bool (*Remove)(void *instance, const PARCObject *element);

    /**
     * Removes from this list all of its elements that are contained in the specified collection (optional operation).
     *
     * @param [in,out] instance A pointer to the instance of `PARCList` to modify
     * @param collection The instance of {@link PARCCollection} whose elements should be found in the @p instance and removed.
     * @return true if the elements are found and removed
     *
     * Example:
     * @code
     * <#example#>
     * @endcode
     */
    bool (*RemoveCollection)(void *instance, const PARCCollection *collection);

    /**
     * Retains only the elements in this list that are contained in the specified collection (optional operation).
     *
     * @param [in,out] instance A pointer to the instance of `PARCList` to modify
     * @param collection The instance of {@link PARCCollection} whose elements should be retained in
     * the @p instance while all other elements are removed.
     * @return true if the operation is successful
     *
     * Example:
     * @code
     * <#example#>
     * @endcode
     */
    bool (*RetainCollection)(void *instance, const PARCCollection *collection);

    /**
     * Replaces the element at the specified position in this list with the specified element (optional operation).
     *
     * @param [in,out] instance A pointer to the instance of `PARCList` to modify
     * @param index The position in @p instance to replace with @p element
     * @param element The element to put into @p instance at @p index, replacing the current value.
     * @return
     *
     * Example:
     * @code
     * <#example#>
     * @endcode
     */
    void *(*SetAtIndex)(void *instance, size_t index, PARCObject * element);

    /**
     * Returns the number of elements in this list.
     *
     * @param [in] instance A pointer to the instance of `PARCList` to inspect
     * @return size_t Number of elements in the list
     *
     * Example:
     * @code
     * <#example#>
     * @endcode
     */
    size_t (*Size)(const void *instance);

    /**
     * Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
     *
     * @param [in] instance A pointer to the instance of `PARCList` to inspect
     * @param [in] fromIndex The starting index into the list
     * @param [in] toIndex The end index into the list
     * @return A pointer to the sub list
     *
     * Example:
     * @code
     * <#example#>
     * @endcode
     */
    PARCList *(*SubList)(const void *instance, size_t fromIndex, size_t toIndex);

    /**
     * Returns an array containing all of the elements in this list in proper sequence (from first to last element).
     *
     * @param [in] instance A pointer to the instance of `PARCList` to inspect
     * @return A pointer to a pointer to the array containing the elements of the list in proper sequence.
     *
     * Example:
     * @code
     * <#example#>
     * @endcode
     */
    void** (*ToArray)(const void *instance);
} PARCListInterface;

/**
 * Increase the number of references to a `PARCList`.
 *
 * Note that new `PARCList` is not created,
 * only that the given `PARCList` reference count is incremented.
 * Discard the reference by invoking `parcList_Release`.
 *
 * @param list A pointer to the original `PARCList`.
 * @return The value of the input parameter @p list.
 *
 * Example:
 * @code
 * {
 *     PARCList *list = parcList(parcArrayList_Create(parcArrayList_StdlibFreeFunction), PARCArrayListAsPARCList);
 *
 *     PARCList *list2 = parcList_Acquire(list);
 *
 *     parcList_Release(&list);
 *     parcList_Release(&list2);
 * }
 * @endcode
 *
 * @see parcList_Release
 */
PARCList *parcList_Acquire(const PARCList *list);

/**
 * Release a previously acquired reference to the specified instance,
 * decrementing the reference count for the instance.
 *
 * The pointer to the instance is set to NULL as a side-effect of this function.
 *
 * If the invocation causes the last reference to the instance to be released,
 * the instance is deallocated and the instance's interface will perform
 * additional cleanup and release other privately held references.
 *
 * @param [in,out] listPtr A pointer to a pointer to the instance to release.
 *
 * Example:
 * @code
 * {
 *     PARCList *list = parcList(parcArrayList_Create(parcArrayList_StdlibFreeFunction), PARCArrayListAsPARCList);
 *
 *     parcList_Release(&list);
 * }
 * @endcode
 */
void parcList_Release(PARCList **listPtr);

/**
 * Create an independent copy the given `PARCList`
 *
 * A new list is created as a complete copy of the original.
 *
 * @param [in] list A valid pointer to a `PARCList` instance (cannot be NULL)
 *
 * @return NULL Memory could not be allocated.
 * @return non-NULL A pointer to a new `PARCList` instance.
 *
 * @throws trapIllegalValue if @p instance is NULL.
 *
 * Example:
 * @code
 * {
 *     PARCList *list = parcList(parcArrayList_Create(parcArrayList_StdlibFreeFunction), PARCArrayListAsPARCList);
 *
 *     PARCList *copy = parcList_Copy(list);
 *
 *     parcList_Release(&copy);
 *     parcList_Release(&list);
 * }
 * @endcode
 *
 */
PARCList *parcList_Copy(const PARCList *list);

/**
 * Tests if this list is empty.
 *
 *   Return true if the list is empty, false otherwise
 *
 * @param list A pointer to the instance of `PARCList` to test
 * @return True if the list is empty, else False
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool parcList_IsEmpty(const PARCList *list);

/**
 * Appends the specified element to the end of this list (optional operation).
 *
 * @param [in,out] list A pointer to the instance of `PARCList` to modify
 * @param [in] element The element to add to the end of the `PARCList`
 * @return True if the add is successful
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool parcList_Add(PARCList *list, void *element);

/**
 * Add all of the pointers in the given array of pointers to the `PARCList`.
 *
 * @param [in,out] list A pointer to the `PARCList` instance to be modified.
 * @param [in] argc The number of values in @p argv.
 * @param [in] argv An array void * values.
 *
 * @return True if the add is successful
 *
 * Example:
 * @code
 * {
 *   PARCList *list = parcList(parcArrayList_Create(NULL), PARCArrayListAsPARCList);
 *
 *   int elements[] = { 1, 2, 3 };
 *
 *   parcList_AddAll(array, 3, elements);
 *   size_t actual = parcList_Length(array);
 *
 *   assertTrue(3 == actual, "Expected=%d, actual=%d", 3, actual);
 *
 *   parcListRelease(&array);
 * }
 * @endcode
 */
bool parcList_AddAll(PARCList *list, size_t argc, void **argv);

/**
 * Inserts the specified element at the specified position in this list (optional operation).
 *
 * @param [in,out] list A pointer to the `PARCList` instance to be modified
 * @param [in] index The specified position in the list
 * @param [in] element The element to be added to the specified position.
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
void parcList_AddAtIndex(PARCList *list, int index, void *element);

/**
 *   Appends all of the elements in the specified collection to the end of this list,
 *    in the order that they are returned by the specified collection's iterator (optional operation).
 *
 * @param [in,out] list A pointer to the `PARCList` instance to be modified
 * @param [in] collection A pointer to an istance of {@link PARCCollection} to be added to the list
 * @return True if add is successful
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool parcList_AddCollection(PARCList *list, PARCCollection *collection);

/**
 * Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
 *
 * @param [in,out] list A pointer to the `PARCList` instance to be modified
 * @param [in] index The position at which to insert the collection
 * @param [in] collection A pointer to an istance of {@link PARCCollection} to be inserted into the list
 * @return True if insertion is successful
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool parcList_AddCollectionAtIndex(PARCList *list, int index, PARCCollection *collection);

/**
 * Removes all of the elements from this list (optional operation).
 *
 * @param [in,out] list A pointer to the `PARCList` instance to be cleared
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
void parcList_Clear(PARCList *list);

/**
 * Returns true if this list contains the specified element.
 *
 * @param [in] list A pointer to the `PARCList` instance to be checked
 * @param [in] element The element to be added to the specified position.
 * @return True if the element is contained in the list
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool parcList_Contains(const PARCList *list, void *element);

/**
 * Returns true if this list contains all of the elements of the specified collection.
 *
 * @param [in] list A pointer to the `PARCList` instance to be checked
 * @param [in] collection A pointer to the instance of {@link PARCCollection} to be checked.
 * @return True if all of the elements in the collection are found in the list.
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool parcList_ContainsCollection(PARCList *list, PARCCollection *collection);


/**
 * Determine if two `PARCList` instances are equal.
 *
 * Two `PARCList` instances are equal if, and only if,
 * the size of the lists are equal and each element in the list is equal and
 * in the same order.
 *
 * The following equivalence relations on non-null `PARCList` instances are maintained:
 *
 *  * It is reflexive: for any non-null reference value x, `PARCList_Equals(x, x)`
 *      must return true.
 *
 *  * It is symmetric: for any non-null reference values x and y,
 *    `parcList_Equals(x, y)` must return true if and only if
 *        `parcList_Equals(y, x)` returns true.
 *
 *  * It is transitive: for any non-null reference values x, y, and z, if
 *        `parcList_Equals(x, y)` returns true and
 *        `parcList_Equals(y, z)` returns true,
 *        then  `parcList_Equals(x, z)` must return true.
 *
 *  * It is consistent: for any non-null reference values x and y, multiple
 *      invocations of `parcList_Equals(x, y)` consistently return true or
 *      consistently return false.
 *
 *  * For any non-null reference value x, `parcList_Equals(x, NULL)` must
 *      return false.
 *
 * @param [in] x A pointer to a `PARCList` instance.
 * @param [in] y A pointer to a `PARCList` instance.
 * @return true if the two `PARCList` instances are equal.
 *
 * Example:
 * @code
 * {
 *    PARCList *a = parcList_Create();
 *    PARCList *b = parcList_Create();
 *
 *    if (parcList_Equals(a, b)) {
 *        // true
 *    } else {
 *        // false
 *    }
 * }
 * @endcode
 */
bool parcList_Equals(const PARCList *x, const PARCList *y);

/**
 * Returns the element at the specified position in this list.
 * If the index is out of bounds, it will trap with an out-of-bounds.
 *
 * @param [in] list A pointer to the `PARCList` instance to be checked
 * @param [in] index The index of the element to be returned
 * @return A pointer to the element.
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
void *parcList_GetAtIndex(const PARCList *list, size_t index);

/**
 * Returns the hash code value for this list.
 *
 * @param [in] list A pointer to the `PARCList` instance to be hashed
 * @return The hash code value
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
int parcList_HashCode(const PARCList *list);

/**
 * Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
 *
 * @param [in] list A pointer to the `PARCList` instance to be hashed.
 * @param [in] element A pointer to an element to check for list inclusion.
 * @return The index of the first occurance of @p element, or -1 if it is not present
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
ssize_t parcList_IndexOf(const PARCList *list, PARCObject *element);

/**
 * Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
 *
 * @param [in] list A pointer to the `PARCList` instance to be hashed.
 * @param [in] element A pointer to an element to check for list inclusion.
 * @return The index of the last occurance of @p element, or -1 if it is not present
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
ssize_t parcList_LastIndexOf(const PARCList *list, PARCObject *element);

/**
 * Removes the element at the specified position in this list (optional operation).
 *
 * @param [in,out] list A pointer to the `PARCList` instance to be modified.
 * @param [in] index  The index of the element to be removed
 * @return  non NULL A pointer to the element removed
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
void *parcList_RemoveAtIndex(PARCList *list, size_t index);

/**
 * Removes the first occurrence of the specified element from this list, if it is present (optional operation).
 *
 * @param [in,out] list A pointer to the `PARCList` instance to be modified.
 * @param [in] element A pointer to the element to be removed from the `PARCList`
 * @return true The element was found and removed, false if it was not found.
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool parcList_Remove(PARCList *list, PARCObject *element);

/**
 * Removes from this list all of its elements that are contained in the specified collection (optional operation).
 *
 * @param [in,out] list A pointer to the `PARCList` instance to be modified.
 * @param [in] collection A pointer to the instance of {@link PARCCollection} to be removed from the `PARCList`
 * @return true The collection was found and removed, false if it was not found.
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool parcList_RemoveCollection(PARCList *list, PARCCollection *collection);

/**
 * Retains only the elements in this list that are contained in the specified collection (optional operation).
 *
 * @param [in,out] list A pointer to the `PARCList` instance to be modified.
 * @param [in] collection A pointer to the instance of {@link PARCCollection} to be found and retained in the `PARCList`
 * @return true if the function was successful
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
bool parcList_RetainCollection(PARCList *list, PARCCollection *collection);

/**
 * Replaces the element at the specified position in this list with the specified element (optional operation).
 *
 * @param [in,out] list A pointer to the `PARCList` instance to be modified.
 * @param [in] index The position at which the element should be replaced with @p element
 * @param [in] element A pointer to the element to be inserted at the specified position
 * @return A pointer to the element previously at that position.
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
PARCObject *parcList_SetAtIndex(PARCList *list, size_t index, PARCObject *element);

/**
 * Returns the number of elements in this list.
 *
 * @param [in] list A pointer to the `PARCList` instance to be measured.
 * @return The size of the @p list
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
size_t parcList_Size(const PARCList *list);

/**
 * Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
 *
 * @param [in] list A pointer to the `PARCList` instance to be measured.
 * @param [in] fromIndex The position to start the view (inclusive)
 * @param [in] toIndex The position to end the view (exclusive)
 * @return a pointer to an instance of `PARCList` containing the subList requested
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
PARCList *parcList_SubList(PARCList *list, size_t fromIndex, size_t toIndex);

/**
 * Returns an array containing all of the elements in this list in proper sequence (from first to last element).
 *
 * @param [in] list A pointer to the `PARCList` instance to be sorted.
 * @return A pointer to a pointer to an Array containing the sorted elements
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
void**parcList_ToArray(PARCList *list);

/**
 * Create an instance of `PARCList` that uses the @p interface to provide functions and the @p instance to provide
 * initial elements of the list.
 * @param [in] instance  An initial set of elements for the new instance of `PARCList`
 * @param [in] interface A pointer to an instance of {@link PARCListInterface} containing a set of list functions
 * @return A pointer to a new instance of `PARCList`
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
PARCList *parcList(void *instance, PARCListInterface *interface);

/**
 * Create an instance of `PARCList` that uses the @p interface to provide functions and the @p instance to provide
 * initial elements of the list.
 * @param [in] instance  An initial set of elements for the new instance of `PARCList`
 * @param [in] interface A pointer to an instance of {@link PARCListInterface} containing a set of list functions
 * @return A pointer to a new instance of `PARCList`
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
PARCList *parcList_Create(void *instance, PARCListInterface *interface);

#endif // libparc_parc_List_h