-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDelphiDabbler.Lib.ArrayUtils.pas
More file actions
3079 lines (2826 loc) · 127 KB
/
DelphiDabbler.Lib.ArrayUtils.pas
File metadata and controls
3079 lines (2826 loc) · 127 KB
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
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/
*
* Copyright (C) 2025, Peter Johnson (www.delphidabbler.com).
*
* Defines an advanced record type that acts as a container for static class
* methods that manipulate generic arrays.
}
unit DelphiDabbler.Lib.ArrayUtils;
// Delphi XE or later is required to compile
// For Delphi XE2 and later we use scoped unit names
{$UNDEF CanCompile}
{$UNDEF SupportsUnitScopeNames}
{$IFDEF CONDITIONALEXPRESSIONS}
{$IF CompilerVersion >= 24.0} // Delphi XE3 and later
{$LEGACYIFEND ON} // NOTE: this must come before all $IFEND directives
{$IFEND}
{$IF CompilerVersion >= 23.0} // Delphi XE2 and later
{$DEFINE SupportsUnitScopeNames}
{$IFEND}
{$IF CompilerVersion >= 22.0} // Delphi XE and later
{$DEFINE CanCompile}
{$IFEND}
{$ENDIF}
{$IFNDEF CanCompile}
{$MESSAGE FATAL 'Delphi XE or later required'}
{$ENDIF}
interface
uses
{$IFDEF SupportsUnitScopeNames}
System.SysUtils
, System.Generics.Defaults
{$ELSE}
SysUtils
, Generics.Defaults
{$ENDIF}
;
type
/// <summary>Container for methods that assist with manipulation of generic
/// arrays.</summary>
TArrayUtils = record
strict private
/// <summary>Returns the minimum value of integers <c>A</c> and <c>B</c>.
/// </summary>
class function IntMin(const A, B: Integer): Integer; static;
/// <summary>Returns the maximum value of integers <c>A</c> and <c>B</c>.
/// </summary>
class function IntMax(const A, B: Integer): Integer; static;
/// <summary>Ensures that an integer value fits within a range.</summary>
/// <param name="AValue"><c>Integer</c> [in] Value to checked.</param>
/// <param name="ARangeLo"><c>Integer</c> [in] Lower bound of the range.
/// </param>
/// <param name="ARangeHi"><c>Integer</c> [in] Upper bound of the range.
/// </param>
/// <returns><c>Integer</c>. <c>AValue</c> if it falls within the range
/// bounds, <c>ARangeLo</c> if it is greater that <c>AValue</c> or
/// <c>ARangeHi</c> if it is less than <c>AValue</c>.</returns>
class procedure ClampInRange(var AValue: Integer;
const ARangeLo, ARangeHi: Integer); static;
/// <summary>Adjusts the starting and ending indexes of a contiguous range
/// of array elements to fit within the bounds of the array and outputs
/// the length of the range.</summary>
/// <param name="AArrayLength"><c>Integer</c> [in] The length of the array
/// in question.</param>
/// <param name="AStartIndex"><c>Integer</c> [in/out] The proposed starting
/// index of the range. Set to <c>0</c> if negative, otherwise left
/// unchanged.</param>
/// <param name="AEndIndex"><c>Integer</c> [in/out] The proposed ending
/// index of the range. Set to <c>AArrayLength - 1</c> if <c>AEndIndex</c>
/// >= <c>AArrayLength</c>, otherwise left unchanged.</param>
/// <param name="ARangeLength"><c>Integer</c> [out] Set to the length of
/// the range defined by the adjusted values of <c>AStartIndex</c> and
/// <c>AEndIndex</c>. Will be <c>0</c> if <c>AEndIndex</c> <
/// <c>AStartIndex</c>.</param>
class procedure NormaliseArrayRange(const AArrayLength: Integer;
var AStartIndex, AEndIndex: Integer; out ARangeLength: Integer); static;
/// <summary>Copies one array into another, starting at a given index.
/// </summary>
/// <param name="ADestArray"><c>TArray>T<</c> [in/out] The array
/// being copied into. Updated with the content of <c>ASourceArray</c>.
/// </param>
/// <param name="ADestArrayIdx"><c>Integer</c> [in/out] When called set to
/// the index in <c>ADestArray</c> where the first element of
/// <c>ASourceArray</c> is to be stored. Updated to the index in
/// <c>ADestArray</c> immediately after that where the last element of
/// <c>ASourceArray</c> was stored.</param>
/// <param name="ASourceArray"><c>array of T</c> [in] Array to be copied
/// into <c>ASourceArray</c>.</param>
/// <remarks>
/// <para><c>ADestArray</c> is assumed to be large enough to store the
/// whole of <c>ASourceArray</c>.</para>
/// <para>When the method returns <c>ADestArrayIdx</c> will store the index
/// where the first element of <c>ASourceArray</c> will be stored on any
/// subsequent call to this method.</para>
/// </remarks>
class procedure CopyIntoArray<T>(var ADestArray: TArray<T>;
var ADestArrayIdx: Integer; const ASourceArray: array of T); static;
/// <summary>Removes out of range and, optionally, duplicated values from
/// an array of array indices and returns the cleaned up array.</summary>
/// <param name="AIndices"><c>array of Integer</c> [in] Array of indices to
/// be cleaned up.</param>
/// <param name="AArrayLength"><c>Integer</c> [in] Length of the array to
/// which the indices relate. Any index < <c>0</c> or >=
/// <c>AArrayLength</c> is discarded.</param>
/// <param name="ADeDup"><c>Boolean</c> [in] Flag indicating whether to
/// remove any duplicated indices (<c>True</c>) or to leave duplicates in
/// place (<c>False</c>).</param>
/// <returns><c>TArray<Integer></c>. The cleaned up array of indices.
/// </returns>
class function CleanIndices(const AIndices: array of Integer;
const AArrayLength: Integer; const ADeDup: Boolean): TArray<Integer>;
static;
/// <summary>Moves a range of elements down a given array.</summary>
/// <param name="A"><c>TArray<T></c> [in/out] Array containing the
/// elements to be moved. Updated in place.</param>
/// <param name="ARangeLo"><c>Integer</c> [in] Lowest index that the range
/// of elements is to be moved to.</param>
/// <param name="ARangeLo"><c>Integer</c> [in] Highest index that the range
/// of elements to be moved to.</param>
/// <param name="AOffset"><c>Integer</c> [in] Distance that the range of
/// elements will be moved down.</param>
class procedure ShuffleDown<T>(var A: TArray<T>;
const ARangeLo, ARangeHi, AOffset: Integer); static;
/// <summary>Moves a range of elements up a given array.</summary>
/// <param name="A"><c>TArray<T></c> [in/out] Array containing the
/// elements to be moved. Updated in place.</param>
/// <param name="ARangeLo"><c>Integer</c> [in] Lowest index that the range
/// of elements is to be moved from.</param>
/// <param name="ARangeLo"><c>Integer</c> [in] Highest index that the range
/// of elements is to be moved from.</param>
/// <param name="AOffset"><c>Integer</c> [in] Distance that the range of
/// elements will be moved up.</param>
class procedure ShuffleUp<T>(var A: TArray<T>;
const ARangeLo, ARangeHi, AOffset: Integer); static;
public
type
/// <summary>Type of function that, when called for each element of an
/// array with element type <c>TIn</c>, maps that element's value to a
/// return value of type <c>TOut</c>.</summary>
/// <param name="AValue"><c>TIn</c> [in] Value to be transformed.</param>
/// <returns><c>TOut</c>. The transformed value.</returns>
TTransformer<TIn,TOut> = reference to function (const AValue: TIn): TOut;
/// <summary>Type of function that, when called for each element of an
/// array with element type <c>TIn</c>, maps that element's value to a
/// return value of type <c>TOut</c>.</summary>
/// <param name="AValue"><c>TIn</c> [in] Value to be transformed.</param>
/// <param name="AIndex"><c>Integer</c> [in] Index of <c>AValue</c> in
/// the array.</param>
/// <param name="AArray"><c>array of TIn</c> [in] Array containing
/// <c>AValue</c>.</param>
/// <returns><c>TOut</c>. The transformed value.</returns>
TTransformerEx<TIn,TOut> = reference to function (const AValue: TIn;
const AIndex: Integer; const AArray: array of TIn): TOut;
/// <summary>Type of function that, when called repeatedly for each
/// element of an array, updates an accumulated value that has the same
/// type as the elements of the array.</summary>
/// <param name="AAccumulator"><c>T</c> [in] The value resulting from a
/// previous call to this function, or an initial value provided by the
/// caller.</param>
/// <param name="ACurrent"><c>T</c> [in] The value of the current array
/// element.</param>
/// <returns><c>T</c>. The new accumulated value.</returns>
TReducer<T> = reference to function (const AAccumulator, ACurrent: T): T;
/// <summary>Type of function that, when called repeatedly for each
/// element of an array, updates an accumulated value that has the same
/// type as the elements of the array.</summary>
/// <param name="AAccumulator"><c>T</c> [in] The value resulting from a
/// previous call to this function, or an initial value provided by the
/// caller.</param>
/// <param name="ACurrent"><c>T</c> [in] The value of the current array
/// element.</param>
/// <param name="AIndex"><c>Integer</c> [in] Index of the current array
/// element within the array.</param>
/// <param name="AArray"><c>array of T</c> [in] Reference to the array
/// containing <c>ACurrent</c>.</param>
/// <returns><c>T</c>. The new accumulated value.</returns>
TReducerEx<T> = reference to function (const AAccumulator, ACurrent: T;
const AIndex: Integer; const AArray: array of T): T;
/// <summary>Type of function that, when called repeatedly for each
/// element of an array with element type <c>TIn</c>, updates an
/// accumulated value that has an optionally different type, <c>TOut</c>.
/// </summary>
/// <param name="AAccumulator"><c>TOut</c> [in] The value resulting from
/// a previous call to this function, or an initial value provided by the
/// caller.</param>
/// <param name="ACurrent"><c>TIn</c> [in] The value of the current array
/// element.</param>
/// <returns><c>TOut</c>. The new accumulated value.</returns>
TReducer<TIn,TOut> = reference to function (const AAccumulator: TOut;
const ACurrent: TIn): TOut;
/// <summary>Type of function that, when called repeatedly for each
/// element of an array with element type <c>TIn</c>, updates an
/// accumulated value that has an optionally different type, <c>TOut</c>.
/// </summary>
/// <param name="AAccumulator"><c>TOut</c> [in] The value resulting from
/// a previous call to this function, or an initial value provided by the
/// caller.</param>
/// <param name="ACurrent"><c>TIn</c> [in] The value of the current array
/// element.</param>
/// <param name="AIndex"><c>Integer</c> [in] Index of the current array
/// element within the array.</param>
/// <param name="AArray"><c>array of TIn</c> [in] Reference to the array
/// containing <c>ACurrent</c>.</param>
/// <returns><c>TOut</c>. The new accumulated value.</returns>
TReducerEx<TIn,TOut> = reference to function (const AAccumulator: TOut;
const ACurrent: TIn; const AIndex: Integer;
const AArray: array of TIn): TOut;
/// <summary>Type of function that, when called for each element of an
/// array, checks whether the element conforms to a particular
/// constraint.</summary>
/// <param name="AElem"><c>T</c> [in] The element to be checked.</param>
/// <returns><c>Boolean</c>. <c>True</c> if <c>AElem</c> conforms to the
/// constraint or <c>False</c> if not.</returns>
TConstraint<T> = reference to function (const AElem: T): Boolean;
/// <summary>Type of function that, when called for each element of an
/// array, checks whether the element conforms to a particular
/// constraint.</summary>
/// <param name="AElem"><c>T</c> [in] The element to be checked.</param>
/// <param name="AIndex"><c>Integer</c> [in] Index of <c>AElem</c> within
/// the array.</param>
/// <param name="AArray"><c>array of T</c> [in] Reference to the array
/// containing <c>AElem</c>.</param>
/// <returns><c>Boolean</c>. <c>True</c> if <c>AElem</c> conforms to the
/// constraint or <c>False</c> if not.</returns>
TConstraintEx<T> = reference to function (const AElem: T;
const AIndex: Integer; const AArray: array of T): Boolean;
/// <summary>Callback procedure that, when called for each element of an
/// array, performs a user defined action.</summary>
/// <param name="AElem"><c>T</c> [in] The current array element.</param>
TCallback<T> = reference to procedure (const AElem: T);
/// <summary>Callback procedure that, when called for each element of an
/// array, performs a user defined action.</summary>
/// <param name="AElem"><c>T</c> [in] The current array element.</param>
/// <param name="AIndex"><c>Integer</c> [in] Index of <c>AElem</c> within
/// the array.</param>
/// <param name="AArray"><c>array of T</c> [in] Reference to the array
/// containing <c>AElem</c>.</param>
TCallbackEx<T> = reference to procedure (const AElem: T;
const AIndex: Integer; const AArray: array of T);
/// <summary>Reference to a function that, when called for each element
/// of an array, returns a deep copy of that element.</summary>
/// <param name="AElem"><c>T</c> [in] Element to be copied.</param>
/// <returns><c>T</c>. The required deep copy of <c>AElem</c>.</returns>
TCloner<T> = reference to function (const AElem: T): T;
public
/// <summary>Returns the first element of a non-empty array</summary>
/// <param name="A"><c>array of T</c> [in] Array on which to operate.
/// </param>
/// <returns><c>T</c>. The first element of <c>A</c>.</returns>
/// <exception><c>EAssertionFailed</c> raised if <c>A</c> is empty.
/// </exception>
class function First<T>(const A: array of T): T;
static;
/// <summary>Returns the last element of a non-empty array.</summary>
/// <param name="A"><c>array of T</c> [in] Array on which to operate.
/// </param>
/// <returns><c>T</c>. The last element of <c>A</c>.</returns>
/// <exception><c>EAssertionFailed</c> raised if <c>A</c> is empty.
/// </exception>
class function Last<T>(const A: array of T): T;
static;
/// <summary>Returns a shallow copy of an array.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be copied.</param>
/// <returns><c>TArray<T></c>. The required copy.</returns>
class function Copy<T>(const A: array of T): TArray<T>;
overload; static;
/// <summary>Returns a deep copy of an array.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be copied.</param>
/// <param name="ACloner"><c>TCloner<T></c> [in] Function called for
/// each element of <c>A</c> that makes a deep copy of the element that is
/// then stored in the resulting array.</param>
/// <returns><c>TArray<T></c>. The required copy.</returns>
class function Copy<T>(const A: array of T;
const ACloner: TCloner<T>): TArray<T>;
overload; static;
/// <summary>Creates an array containing the concatenation of two arrays.
/// </summary>
/// <param name="A"><c>array of T</c> [in] First array copied to the
/// returned array.</param>
/// <param name="B"><c>array of T</c> [in] Second array copied to the
/// returned array.</param>
/// <returns><c>TArray<T></c>. The required concatenation comprising
/// shallow copies of <c>A</c> and <c>B</c>.</returns>
class function Concat<T>(const A, B: array of T): TArray<T>;
static;
/// <summary>Returns an array comprising a shallow copy of elements of an
/// array that occur at specified indices in the array.</summary>
/// <param name="A"><c>array of T</c> [in] Array from which the returned
/// elements are to be picked.</param>
/// <param name="AIndices"><c>array of Integer</c> [in] The indices in
/// <c>A</c> of the elements to be returned. If any index is out of range
/// in <c>A</c> then it is ignored.</param>
/// <returns><c>TArray<T></c>. An array containing the chosen
/// elements. The array contains the elements in the order their indices
/// occur in <c>AIndices</c>. If any index is repeated in <c>AIndices</c>
/// then the associated element is repeated in the returned array.
/// </returns>
class function Pick<T>(const A: array of T;
const AIndices: array of Integer): TArray<T>;
static;
/// <summary>Returns an array comprising a shallow copy of a contiguous
/// range of elements from an array.</summary>
/// <param name="A"><c>array of T</c> [in] Array from which the slice is to
/// be copied.</param>
/// <param name="AStartIndex"><c>Integer</c> [in] The index in <c>A</c> of
/// the start of the slice.</param>
/// <param name="AEndIndex"><c>Integer</c> [in] The index in <c>A</c> of
/// the end of the slice.</param>
/// <returns><c>TArray<T></c>. The required slice.</returns>
/// <remarks>
/// <para>If <c>AStartIndex</c> <= <c>0</c> then the slice begins at the
/// first element of <c>A</c>.</para>
/// <para>If <c>AEndIndex</c> >= <c>Length(A)</c> then the slice
/// continues to the end of <c>A</c>.</para>
/// <para>If <c>AEndIndex</c> is < <c>AStartIndex</c> then an empty
/// array is returned.</para>
/// </remarks>
class function Slice<T>(const A: array of T;
AStartIndex, AEndIndex: Integer): TArray<T>;
overload; static;
/// <summary>Returns an array comprising a shallow copy of a contiguous
/// range of elements at the end of an array.</summary>
/// <param name="A"><c>array of T</c> [in] Array from which the slice is to
/// be copied.</param>
/// <param name="AStartIndex"><c>Integer</c> [in] The index in <c>A</c> of
/// the start of the slice.</param>
/// <returns><c>TArray<T></c>. The required slice, which runs from
/// <c>AStartIndex</c> to the end of <c>A</c>.</returns>
/// <remarks>If <c>AStartIndex</c> <= <c>0</c> then a copy of the whole
/// of <c>A</c> is returned.</remarks>
class function Slice<T>(const A: array of T;
AStartIndex: Integer): TArray<T>;
overload; static;
/// <summary>Removes a contiguous range of elements from an array and
/// returns an array containing a shallow copy of the removed elements.
/// </summary>
/// <param name="A"><c>array of T</c> [in/out] Array from which the range
/// of elements is to be removed. The modified array is passed out.</param>
/// <param name="AStartIndex"><c>Integer</c> [in] The index in <c>A</c> of
/// the start of the removed range of elements.</param>
/// <param name="AEndIndex"><c>Integer</c> [in] The index in <c>A</c> of
/// the end of the removed range of elements.</param>
/// <returns><c>TArray<T></c>. Copy of the removed range of elements.
/// </returns>
/// <remarks>
/// <para>If <c>AStartIndex</c> <= <c>0</c> then the chop begins at the
/// first element of <c>A</c>.</para>
/// <para>If <c>AEndIndex</c> >= <c>Length(A)</c> then the chop
/// continues to the end of <c>A</c>.</para>
/// <para>If <c>AEndIndex</c> is < <c>AStartIndex</c> then no change is
/// made to <c>A</c> and an empty array is returned.</para>
/// </remarks>
class function Chop<T>(var A: TArray<T>;
AStartIndex, AEndIndex: Integer): TArray<T>;
overload; static;
/// <summary>Removes a contiguous range of elements from the end of an
/// array and returns an array containing a shallow copy of the removed
/// elements.</summary>
/// <param name="A"><c>array of T</c> [in/out] Array from which the range
/// of elements is to be removed. The modified array is passed out.</param>
/// <param name="AStartIndex"><c>Integer</c> [in] The index in <c>A</c> of
/// the start of the removed range of elements.</param>
/// <returns><c>TArray<T></c>. Copy of the removed range of elements,
/// which runs from <c>AStartIndex</c> to the end of <c>A</c>.</returns>
/// <remarks>If <c>AStartIndex</c> <= <c>0</c> then all elements of
/// <c>A</c> are deleted and a copy of the whole of <c>A</c> is returned.
/// </remarks>
class function Chop<T>(var A: TArray<T>; AStartIndex: Integer): TArray<T>;
overload; static;
/// <summary>Finds the first index of an element of type <c>T</c> in a
/// given array that matches a given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <param name="AEqualityComparer"><c>TEqualityComparison<T></c>
/// [in] Reference to a function used to determine if two values of type
/// <c>T</c> are equal. Used to test <c>AItem</c> for equality with
/// elements of <c>A</c>.</param>
/// <returns><c>Integer</c>. The lowest index of an element of <c>A</c>
/// that tests equal to <c>AItem</c> or <c>-1</c> if <c>A</c> contains no
/// matching element.</returns>
class function IndexOf<T>(const AItem: T; const A: array of T;
const AEqualityComparer: TEqualityComparison<T>): Integer;
overload; static;
/// <summary>Finds the first index of an element of type <c>T</c> in a
/// given array that matches a given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <param name="AEqualityComparer"><c>IEqualityComparer<T></c> [in]
/// Reference to an object that can be used to determine if two values of
/// type <c>T</c> are equal. Used to test <c>AItem</c> for equality with
/// elements of <c>A</c>.</param>
/// <returns><c>Integer</c>. The lowest index of an element of <c>A</c>
/// that tests equal to <c>AItem</c> or <c>-1</c> if <c>A</c> contains no
/// matching element.</returns>
class function IndexOf<T>(const AItem: T; const A: array of T;
const AEqualityComparer: IEqualityComparer<T>): Integer;
overload; static;
/// <summary>Finds the first index of an element of type <c>T</c> in a
/// given array that matches a given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <returns><c>Integer</c>. The lowest index of an element of <c>A</c>
/// that tests equal to <c>AItem</c> or <c>-1</c> if <c>A</c> contains no
/// matching element.</returns>
/// <remarks>The default equality comparer for type <c>T</c> is used to
/// test <c>AItem</c> for equality with the elements of <c>A</c>.</remarks>
class function IndexOf<T>(const AItem: T; const A: array of T): Integer;
overload; static;
/// <summary>Finds the last index of an element of type <c>T</c> in a
/// given array that matches a given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <param name="AEqualityComparer"><c>TEqualityComparison<T></c>
/// [in] Reference to a function used to determine if two values of type
/// <c>T</c> are equal. Used to test <c>AItem</c> for equality with
/// elements of <c>A</c>.</param>
/// <returns><c>Integer</c>. The greatest index of an element of <c>A</c>
/// that tests equal to <c>AItem</c> or <c>-1</c> if <c>A</c> contains no
/// matching element.</returns>
class function LastIndexOf<T>(const AItem: T; const A: array of T;
const AEqualityComparer: TEqualityComparison<T>): Integer;
overload; static;
/// <summary>Finds the last index of an element of type <c>T</c> in a
/// given array that matches a given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <param name="AEqualityComparer"><c>IEqualityComparer<T></c> [in]
/// Reference to an object that can be used to determine if two values of
/// type <c>T</c> are equal. Used to test <c>AItem</c> for equality with
/// elements of <c>A</c>.</param>
/// <returns><c>Integer</c>. The greatest index of an element of <c>A</c>
/// that tests equal to <c>AItem</c> or <c>-1</c> if <c>A</c> contains no
/// matching element.</returns>
class function LastIndexOf<T>(const AItem: T; const A: array of T;
const AEqualityComparer: IEqualityComparer<T>): Integer;
overload; static;
/// <summary>Finds the last index of an element of type <c>T</c> in a
/// given array that matches a given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <returns><c>Integer</c>. The greatest index of an element of <c>A</c>
/// that tests equal to <c>AItem</c> or <c>-1</c> if <c>A</c> contains no
/// matching element.</returns>
/// <remarks>The default equality comparer for type <c>T</c> is used to
/// test <c>AItem</c> for equality with the elements of <c>A</c>.</remarks>
class function LastIndexOf<T>(const AItem: T; const A: array of T): Integer;
overload; static;
/// <summary>Finds the indices of all elements in an array that match a
/// given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <param name="AEqualityComparer"><c>TEqualityComparison<T></c>
/// [in] Reference to a function used to determine if two values of type
/// <c>T</c> are equal. Used to test <c>AItem</c> for equality with
/// elements of <c>A</c>.</param>
/// <returns><c>TArray<Integer></c>. The indices of elements of
/// <c>A</c> that test equal to <c>AItem</c>. An empty array is returned if
/// <c>A</c> contains no matching element.</returns>
class function IndicesOf<T>(const AItem: T; const A: array of T;
const AEqualityComparer: TEqualityComparison<T>): TArray<Integer>;
overload; static;
/// <summary>Finds the indices of all elements in an array that match a
/// given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <param name="AEqualityComparer"><c>IEqualityComparer<T></c> [in]
/// Reference to an object that can be used to determine if two values of
/// type <c>T</c> are equal. Used to test <c>AItem</c> for equality with
/// elements of <c>A</c>.</param>
/// <returns><c>TArray<Integer></c>. The indices of elements of
/// <c>A</c> that test equal to <c>AItem</c>. An empty array is returned if
/// <c>A</c> contains no matching element.</returns>
class function IndicesOf<T>(const AItem: T; const A: array of T;
const AEqualityComparer: IEqualityComparer<T>): TArray<Integer>;
overload; static;
/// <summary>Finds the indices of all elements in an array that match a
/// given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <returns><c>TArray<Integer></c>. The indices of elements of
/// <c>A</c> that test equal to <c>AItem</c>. An empty array is returned if
/// <c>A</c> contains no matching element.</returns>
/// <remarks>The default equality comparer for type <c>T</c> is used to
/// test <c>AItem</c> for equality with the elements of <c>A</c>.</remarks>
class function IndicesOf<T>(const AItem: T;
const A: array of T): TArray<Integer>;
overload; static;
/// <summary>Checks if an array contains at least one element that matches
/// a given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <param name="AEqualityComparer"><c>TEqualityComparison<T></c>
/// [in] Reference to a function used to determine if two values of type
/// <c>T</c> are equal. Used to test <c>AItem</c> for equality with
/// elements of <c>A</c>.</param>
/// <returns><c>Boolean</c>. <c>True</c> if <c>A</c> contains at least one
/// element that tests equal to <c>AItem</c>, or <c>False</c> if not.
/// </returns>
class function Contains<T>(const AItem: T; const A: array of T;
const AEqualityComparer: TEqualityComparison<T>): Boolean;
overload; static;
/// <summary>Checks if an array contains at least one element that matches
/// a given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <param name="AEqualityComparer"><c>IEqualityComparer<T></c> [in]
/// Reference to an object that can be used to determine if two values of
/// type <c>T</c> are equal. Used to test <c>AItem</c> for equality with
/// elements of <c>A</c>.</param>
/// <returns><c>Boolean</c>. <c>True</c> if <c>A</c> contains at least one
/// element that tests equal to <c>AItem</c>, or <c>False</c> if not.
/// </returns>
class function Contains<T>(const AItem: T; const A: array of T;
const AEqualityComparer: IEqualityComparer<T>): Boolean;
overload; static;
/// <summary>Checks if an array contains at least one element that matches
/// a given item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <returns><c>Boolean</c>. <c>True</c> if <c>A</c> contains at least one
/// element that tests equal to <c>AItem</c>, or <c>False</c> if not.
/// </returns>
/// <remarks>The default equality comparer for type <c>T</c> is used to
/// test <c>AItem</c> for equality with the elements of <c>A</c>.</remarks>
class function Contains<T>(const AItem: T; const A: array of T): Boolean;
overload; static;
/// <summary>Counts the number of elements in an array that match a given
/// item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <param name="AEqualityComparer"><c>TEqualityComparison<T></c>
/// [in] Reference to a function used to determine if two values of type
/// <c>T</c> are equal. Used to test <c>AItem</c> for equality with
/// elements of <c>A</c>.</param>
/// <returns><c>Integer</c>. The number of elements of <c>A</c> that test
/// equal to <c>AItem</c>. <c>0</c> is returned if there are no such
/// elements.</returns>
class function OccurrencesOf<T>(const AItem: T; const A: array of T;
const AEqualityComparer: TEqualityComparison<T>): Integer;
overload; static;
/// <summary>Counts the number of elements in an array that match a given
/// item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <param name="AEqualityComparer"><c>IEqualityComparer<T></c> [in]
/// Reference to an object that can be used to determine if two values of
/// type <c>T</c> are equal. Used to test <c>AItem</c> for equality with
/// elements of <c>A</c>.</param>
/// <returns><c>Integer</c>. The number of elements of <c>A</c> that test
/// equal to <c>AItem</c>. <c>0</c> is returned if there are no such
/// elements.</returns>
class function OccurrencesOf<T>(const AItem: T; const A: array of T;
const AEqualityComparer: IEqualityComparer<T>): Integer;
overload; static;
/// <summary>Counts the number of elements in an array that match a given
/// item.</summary>
/// <param name="AItem"><c>T</c> [in] Item to search for in the array.
/// </param>
/// <param name="A"><c>array of T</c> [in] Array to be searched.</param>
/// <returns><c>Integer</c>. The number of elements of <c>A</c> that test
/// equal to <c>AItem</c>. <c>0</c> is returned if there are no such
/// elements.</returns>
/// <remarks>The default equality comparer for type <c>T</c> is used to
/// test <c>AItem</c> for equality with the elements of <c>A</c>.</remarks>
class function OccurrencesOf<T>(const AItem: T;
const A: array of T): Integer;
overload; static;
/// <summary>Attempts to find the first element of an array for which a
/// given constraint function returns <c>True</c>. Returns a <c>Boolean</c>
/// that indicates success or failure.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraint<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element. Returns <c>True</c> if the element
/// meets the required criteria or <c>False</c> otherwise.</param>
/// <param name="AItem"><c>T</c> [out] Set to the first element of <c>A</c>
/// for which <c>AConstraint</c> returns <c>True</c>. Undefined if no such
/// element is found.</param>
/// <returns><c>Boolean</c>. <c>True</c> if an element for which
/// <c>AConstraint</c> returns <c>True</c> is found, <c>False</c>
/// otherwise.</returns>
class function TryFind<T>(const A: array of T;
const AConstraint: TConstraint<T>; out AItem: T): Boolean;
overload; static;
/// <summary>Attempts to find the first element of an array for which a
/// given constraint function returns <c>True</c>. Returns a <c>Boolean</c>
/// that indicates success or failure.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraintEx<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element, the index of the current element in
/// <c>A</c> and a reference to <c>A</c>. Returns <c>True</c> if the
/// element meets the required criteria or <c>False</c> otherwise.</param>
/// <param name="AItem"><c>T</c> [out] Set to the first element of <c>A</c>
/// for which <c>AConstraint</c> returns <c>True</c>. Undefined if no such
/// element is found.</param>
/// <returns><c>Boolean</c>. <c>True</c> if an element for which
/// <c>AConstraint</c> returns <c>True</c> is found, <c>False</c>
/// otherwise.</returns>
class function TryFind<T>(const A: array of T;
const AConstraint: TConstraintEx<T>; out AItem: T): Boolean;
overload; static;
/// <summary>Attempts to find the last element of an array for which a
/// given constraint function returns <c>True</c>. Returns a <c>Boolean</c>
/// that indicates success or failure.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraint<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element. Returns <c>True</c> if the element
/// meets the required criteria or <c>False</c> otherwise.</param>
/// <param name="AItem"><c>T</c> [out] Set to the last element of <c>A</c>
/// for which <c>AConstraint</c> returns <c>True</c>. Undefined if no such
/// element is found.</param>
/// <returns><c>Boolean</c>. <c>True</c> if an element for which
/// <c>AConstraint</c> returns <c>True</c> is found, <c>False</c>
/// otherwise.</returns>
class function TryFindLast<T>(const A: array of T;
const AConstraint: TConstraint<T>; out AItem: T): Boolean;
overload; static;
/// <summary>Attempts to find the last element of an array for which a
/// given constraint function returns <c>True</c>. Returns a <c>Boolean</c>
/// that indicates success or failure.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraintEx<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element, the index of the current element in
/// <c>A</c> and a reference to <c>A</c>. Returns <c>True</c> if the
/// element meets the required criteria or <c>False</c> otherwise.</param>
/// <param name="AItem"><c>T</c> [out] Set to the last element of <c>A</c>
/// for which <c>AConstraint</c> returns <c>True</c>. Undefined if no such
/// element is found.</param>
/// <returns><c>Boolean</c>. <c>True</c> if an element for which
/// <c>AConstraint</c> returns <c>True</c> is found, <c>False</c>
/// otherwise.</returns>
class function TryFindLast<T>(const A: array of T;
const AConstraint: TConstraintEx<T>; out AItem: T): Boolean;
overload; static;
/// <summary>Finds the first element of an array for which a given
/// constraint function returns <c>True</c>, or chooses a default value if
/// no such element exists.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraint<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element. Returns <c>True</c> if the element
/// meets the required criteria or <c>False</c> otherwise.</param>
/// <param name="ADefault"><c>T</c> [in] Default value to be returned if
/// <c>AConstraint</c> does not return <c>True</c> for any element of
/// <c>A</c>.</param>
/// <returns><c>T</c>. The value of the first element of <c>A</c> for which
/// <c>AConstraint</c> returns <c>True</c>, or <c>ADefault</c> if there is
/// no such element.</returns>
class function FindDef<T>(const A: array of T;
const AConstraint: TConstraint<T>; const ADefault: T): T;
overload; static;
/// <summary>Finds the first element of an array for which a given
/// constraint function returns <c>True</c>, or chooses a default value if
/// no such element exists.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraintEx<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element, the index of the current element in
/// <c>A</c> and a reference to <c>A</c>. Returns <c>True</c> if the
/// element meets the required criteria or <c>False</c> otherwise.</param>
/// <param name="ADefault"><c>T</c> [in] Default value to be returned if
/// <c>AConstraint</c> does not return <c>True</c> for any element of
/// <c>A</c>.</param>
/// <returns><c>T</c>. The value of the first element of <c>A</c> for which
/// <c>AConstraint</c> returns <c>True</c>, or <c>ADefault</c> if there is
/// no such element.</returns>
class function FindDef<T>(const A: array of T;
const AConstraint: TConstraintEx<T>; const ADefault: T): T;
overload; static;
/// <summary>Finds the last element of an array for which a given
/// constraint function returns <c>True</c>, or chooses a default value if
/// no such element exists.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraint<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element. Returns <c>True</c> if the element
/// meets the required criteria or <c>False</c> otherwise.</param>
/// <param name="ADefault"><c>T</c> [in] Default value to be returned if
/// <c>AConstraint</c> does not return <c>True</c> for any element of
/// <c>A</c>.</param>
/// <returns><c>T</c>. The value of the last element of <c>A</c> for which
/// <c>AConstraint</c> returns <c>True</c>, or <c>ADefault</c> if there is
/// no such element.</returns>
class function FindLastDef<T>(const A: array of T;
const AConstraint: TConstraint<T>; const ADefault: T): T;
overload; static;
/// <summary>Finds the last element of an array for which a given
/// constraint function returns <c>True</c>, or chooses a default value if
/// no such element exists.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraintEx<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element, the index of the current element in
/// <c>A</c> and a reference to <c>A</c>. Returns <c>True</c> if the
/// element meets the required criteria or <c>False</c> otherwise.</param>
/// <param name="ADefault"><c>T</c> [in] Default value to be returned if
/// <c>AConstraint</c> does not return <c>True</c> for any element of
/// <c>A</c>.</param>
/// <returns><c>T</c>. The value of the last element of <c>A</c> for which
/// <c>AConstraint</c> returns <c>True</c>, or <c>ADefault</c> if there is
/// no such element.</returns>
class function FindLastDef<T>(const A: array of T;
const AConstraint: TConstraintEx<T>; const ADefault: T): T;
overload; static;
/// <summary>Finds all the elements of an array for which a given
/// constraint function returns <c>True</c>.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraint<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element. Returns <c>True</c> if the element
/// meets the required criteria or <c>False</c> otherwise.</param>
/// <returns><c>TArray<T></c>. Array of elements of <c>A</c> for
/// which <c>AConstraint</c> returns <c>True</c>. Will be empty if no such
/// elements exist.</returns>
class function FindAll<T>(const A: array of T;
const AConstraint: TConstraint<T>): TArray<T>;
overload; static;
/// <summary>Finds all the elements of an array for which a given
/// constraint function returns <c>True</c>.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraintEx<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element, the index of the current element in
/// <c>A</c> and a reference to <c>A</c>. Returns <c>True</c> if the
/// element meets the required criteria or <c>False</c> otherwise.</param>
/// <returns><c>TArray<T></c>. Array of elements of <c>A</c> for
/// which <c>AConstraint</c> returns <c>True</c>. Will be empty if no such
/// elements exist.</returns>
class function FindAll<T>(const A: array of T;
const AConstraint: TConstraintEx<T>): TArray<T>;
overload; static;
/// <summary>Finds the index of the first element of an array for which a
/// given constraint function returns <c>True</c>.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraint<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element. Returns <c>True</c> if the element
/// meets the required criteria or <c>False</c> otherwise.</param>
/// <returns><c>Integer</c>. The index of the first element of <c>A</c> for
/// which <c>AConstraint</c> returns <c>True</c> or <c>-1</c> if <c>A</c>
/// contains no matching element.</returns>
class function FindIndex<T>(const A: array of T;
const AConstraint: TConstraint<T>): Integer;
overload; static;
/// <summary>Finds the index of the first element of an array for which a
/// given constraint function returns <c>True</c>.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraintEx<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element, the index of the current element in
/// <c>A</c> and a reference to <c>A</c>. Returns <c>True</c> if the
/// element meets the required criteria or <c>False</c> otherwise.</param>
/// <returns><c>Integer</c>. The index of the first element of <c>A</c> for
/// which <c>AConstraint</c> returns <c>True</c> or <c>-1</c> if <c>A</c>
/// contains no matching element.</returns>
class function FindIndex<T>(const A: array of T;
const AConstraint: TConstraintEx<T>): Integer;
overload; static;
/// <summary>Finds the index of the last element of an array for which a
/// given constraint function returns <c>True</c>.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraint<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element. Returns <c>True</c> if the element
/// meets the required criteria or <c>False</c> otherwise.</param>
/// <returns><c>Integer</c>. The index of the last element of <c>A</c> for
/// which <c>AConstraint</c> returns <c>True</c> or <c>-1</c> if <c>A</c>
/// contains no matching element.</returns>
class function FindLastIndex<T>(const A: array of T;
const AConstraint: TConstraint<T>): Integer;
overload; static;
/// <summary>Finds the index of the last element of an array for which a
/// given constraint function returns <c>True</c>.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraintEx<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element, the index of the current element in
/// <c>A</c> and a reference to <c>A</c>. Returns <c>True</c> if the
/// element meets the required criteria or <c>False</c> otherwise.</param>
/// <returns><c>Integer</c>. The index of the last element of <c>A</c> for
/// which <c>AConstraint</c> returns <c>True</c> or <c>-1</c> if <c>A</c>
/// contains no matching element.</returns>
class function FindLastIndex<T>(const A: array of T;
const AConstraint: TConstraintEx<T>): Integer;
overload; static;
/// <summary>Finds the indices of all the elements of an array for which a
/// given constraint function returns <c>True</c>.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraint<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element. Returns <c>True</c> if the element
/// meets the required criteria or <c>False</c> otherwise.</param>
/// <returns><c>TArray<Integer></c>. Array of indices of the elements
/// of <c>A</c> for which <c>AConstraint</c> returns <c>True</c>. Will be
/// empty if no such elements exist.</returns>
class function FindAllIndices<T>(const A: array of T;
const AConstraint: TConstraint<T>): TArray<Integer>;
overload; static;
/// <summary>Finds the indices of all the elements of an array for which a
/// given constraint function returns <c>True</c>.</summary>
/// <param name="A"><c>array of T</c> [in] Array to be checked.</param>
/// <param name="AConstraint"><c>TConstraintEx<T></c> [in] Constraint
/// function called for each element of <c>A</c>. The function is passed
/// the value of the current element, the index of the current element in
/// <c>A</c> and a reference to <c>A</c>. Returns <c>True</c> if the
/// element meets the required criteria or <c>False</c> otherwise.</param>
/// <returns><c>TArray<Integer></c>. Array of indices of the elements
/// of <c>A</c> for which <c>AConstraint</c> returns <c>True</c>. Will be
/// empty if no such elements exist.</returns>
class function FindAllIndices<T>(const A: array of T;
const AConstraint: TConstraintEx<T>): TArray<Integer>;
overload; static;
/// <summary>Checks if two arrays have the same contents, in the same
/// order.</summary>
/// <param name="ALeft"><c>array of T</c> [in] The first array to be
/// checked.</param>
/// <param name="ARight"><c>array of T</c> [in] The second array to be
/// checked.</param>
/// <param name="AEqualityComparer"><c>TEqualityComparison<T></c>
/// [in] Reference to a function used to determine if two values of type
/// <c>T</c> are equal. Used to test elements of <c>ALeft</c> and
/// <c>ARight</c> for equality.</param>
/// <returns><c>Boolean</c>. <c>True</c> if the arrays are equal,
/// <c>False</c> if not.</returns>
class function Equal<T>(const ALeft, ARight: array of T;
const AEqualityComparer: TEqualityComparison<T>): Boolean;
overload; static;
/// <summary>Checks if two arrays have the same contents, in the same
/// order.</summary>
/// <param name="ALeft"><c>array of T</c> [in] The first array to be
/// checked.</param>
/// <param name="ARight"><c>array of T</c> [in] The second array to be
/// checked.</param>
/// <param name="AEqualityComparer"><c>IEqualityComparer<T></c> [in]
/// Reference to an object that can be used to determine if two values of
/// type <c>T</c> are equal. Used to test elements of <c>ALeft</c> and
/// <c>ARight</c> for equality.</param>
/// <returns><c>Boolean</c>. <c>True</c> if the arrays are equal,
/// <c>False</c> if not.</returns>
class function Equal<T>(const ALeft, ARight: array of T;
const AEqualityComparer: IEqualityComparer<T>): Boolean;
overload; static;
/// <summary>Checks if two arrays have the same contents, in the same
/// order.</summary>
/// <param name="ALeft"><c>array of T</c> [in] The first array to be
/// checked.</param>
/// <param name="ARight"><c>array of T</c> [in] The second array to be
/// checked.</param>
/// <returns><c>Boolean</c>. <c>True</c> if the arrays are equal,
/// <c>False</c> if not.</returns>
/// <remarks>The default equality comparer for type <c>T</c> is used to
/// test the elements and <c>ALeft</c> and <c>ARight</c> for equality.
/// </remarks>
class function Equal<T>(const ALeft, ARight: array of T): Boolean;
overload; static;
/// <summary>Checks if a given number of elements at the start of two
/// arrays are equal.</summary>
/// <param name="ALeft"><c>array of T</c> [in] The first array to be
/// checked.</param>
/// <param name="ARight"><c>array of T</c> [in] The second array to be
/// checked.</param>
/// <param name="ACount"><c>Integer</c> [in] The number of elements at the
/// start of the arrays that must be equal. Must be >= <c>1</c>.</param>
/// <param name="AEqualityComparer"><c>TEqualityComparison<T></c>
/// [in] Reference to a function used to determine if two values of type
/// <c>T</c> are equal. Used to test elements of <c>ALeft</c> and
/// <c>ARight</c> for equality.</param>
/// <returns><c>Boolean</c>. <c>True</c> if the required number of elements
/// are equal or <c>False</c> if the elements are not equal or if either
/// array has fewer than <c>ACount</c> elements.</returns>
/// <exception><c>EAssertionFailed</c> is raised if <c>ACount</c> is not
/// positive.</exception>
class function EqualStart<T>(const ALeft, ARight: array of T;
const ACount: Integer; const AEqualityComparer: TEqualityComparison<T>):
Boolean;
overload; static;
/// <summary>Checks if a given number of elements at the start of two
/// arrays are equal.</summary>
/// <param name="ALeft"><c>array of T</c> [in] The first array to be
/// checked.</param>
/// <param name="ARight"><c>array of T</c> [in] The second array to be
/// checked.</param>
/// <param name="ACount"><c>Integer</c> [in] The number of elements at the
/// start of the arrays that must be equal. Must be >= <c>1</c>.</param>
/// <param name="AEqualityComparer"><c>IEqualityComparer<T></c> [in]
/// Reference to an object that can be used to determine if two values of
/// type <c>T</c> are equal. Used to test elements of <c>ALeft</c> and
/// <c>ARight</c> for equality.</param>
/// <returns><c>Boolean</c>. <c>True</c> if the required number of elements
/// are equal or <c>False</c> if the elements are not equal or if either
/// array has fewer than <c>ACount</c> elements.</returns>
/// <exception><c>EAssertionFailed</c> is raised if <c>ACount</c> is not
/// positive.</exception>
class function EqualStart<T>(const ALeft, ARight: array of T;
const ACount: Integer; const AEqualityComparer: IEqualityComparer<T>):
Boolean;
overload; static;
/// <summary>Checks if a given number of elements at the start of two
/// arrays are equal.</summary>
/// <param name="ALeft"><c>array of T</c> [in] The first array to be
/// checked.</param>
/// <param name="ARight"><c>array of T</c> [in] The second array to be
/// checked.</param>
/// <param name="ACount"><c>Integer</c> [in] The number of elements at the
/// start of the arrays that must be equal. Must be >= <c>1</c>.</param>