|
| 1 | +{ |
| 2 | + * Demo project for the DelphiDabbler.Lib.ArrayUtils unit. |
| 3 | + * |
| 4 | + * Contains copies the example code of all TArrayUtils methods included in the |
| 5 | + * documentation at https://delphidabbler.com/url/arrayutils-docs. |
| 6 | + * |
| 7 | + * This is a console application. |
| 8 | + * |
| 9 | + * Any copyright in this file is dedicated to the Public Domain. |
| 10 | + * http://creativecommons.org/publicdomain/zero/1.0/ |
| 11 | +} |
| 12 | + |
| 13 | +program ArrayUtilsDemo; |
| 14 | + |
| 15 | +{$APPTYPE CONSOLE} |
| 16 | + |
| 17 | +uses |
| 18 | + SysUtils, |
| 19 | + DelphiDabbler.Lib.ArrayUtils in '..\DelphiDabbler.Lib.ArrayUtils.pas', |
| 20 | + Registrar in 'Registrar.pas', |
| 21 | + Chop in 'Examples\Chop.pas', |
| 22 | + Compare in 'Examples\Compare.pas', |
| 23 | + Concat in 'Examples\Concat.pas', |
| 24 | + Contains in 'Examples\Contains.pas', |
| 25 | + Copy in 'Examples\Copy.pas', |
| 26 | + CopyReversed in 'Examples\CopyReversed.pas', |
| 27 | + CopySorted in 'Examples\CopySorted.pas', |
| 28 | + DeDup in 'Examples\DeDup.pas', |
| 29 | + Delete in 'Examples\Delete.pas', |
| 30 | + DeleteAndFree in 'Examples\DeleteAndFree.pas', |
| 31 | + DeleteAndFreeRange in 'Examples\DeleteAndFreeRange.pas', |
| 32 | + DeleteAndRelease in 'Examples\DeleteAndRelease.pas', |
| 33 | + DeleteAndReleaseRange in 'Examples\DeleteAndReleaseRange.pas', |
| 34 | + DeleteRange in 'Examples\DeleteRange.pas', |
| 35 | + Equal in 'Examples\Equal.pas', |
| 36 | + EqualStart in 'Examples\EqualStart.pas', |
| 37 | + Every in 'Examples\Every.pas', |
| 38 | + FindAll in 'Examples\FindAll.pas', |
| 39 | + FindAllIndices in 'Examples\FindAllIndices.pas', |
| 40 | + FindDef in 'Examples\FindDef.pas', |
| 41 | + FindIndex in 'Examples\FindIndex.pas', |
| 42 | + FindLastDef in 'Examples\FindLastDef.pas', |
| 43 | + FindLastIndex in 'Examples\FindLastIndex.pas', |
| 44 | + First in 'Examples\First.pas', |
| 45 | + ForEach in 'Examples\ForEach.pas', |
| 46 | + IndexOf in 'Examples\IndexOf.pas', |
| 47 | + IndicesOf in 'Examples\IndicesOf.pas', |
| 48 | + Insert in 'Examples\Insert.pas', |
| 49 | + Last in 'Examples\Last.pas', |
| 50 | + LastIndexOf in 'Examples\LastIndexOf.pas', |
| 51 | + Max in 'Examples\Max.pas', |
| 52 | + Min in 'Examples\Min.pas', |
| 53 | + MinMax in 'Examples\MinMax.pas', |
| 54 | + OccurrencesOf in 'Examples\OccurrencesOf.pas', |
| 55 | + Pick in 'Examples\Pick.pas', |
| 56 | + Pop in 'Examples\Pop.pas', |
| 57 | + PopAndFree in 'Examples\PopAndFree.pas', |
| 58 | + PopAndRelease in 'Examples\PopAndRelease.pas', |
| 59 | + Push in 'Examples\Push.pas', |
| 60 | + Reduce in 'Examples\Reduce.pas', |
| 61 | + Reverse in 'Examples\Reverse.pas', |
| 62 | + Shift in 'Examples\Shift.pas', |
| 63 | + ShiftAndFree in 'Examples\ShiftAndFree.pas', |
| 64 | + ShiftAndRelease in 'Examples\ShiftAndRelease.pas', |
| 65 | + Slice in 'Examples\Slice.pas', |
| 66 | + Some in 'Examples\Some.pas', |
| 67 | + Sort in 'Examples\Sort.pas', |
| 68 | + Transform in 'Examples\Transform.pas', |
| 69 | + TryFind in 'Examples\TryFind.pas', |
| 70 | + TryFindLast in 'Examples\TryFindLast.pas', |
| 71 | + UnShift in 'Examples\UnShift.pas'; |
| 72 | + |
| 73 | +var |
| 74 | + MethodName: string; |
| 75 | + MethodTitle: string; |
| 76 | + ProcInfo: TProcedureInfo; |
| 77 | + ProcTitle: string; |
| 78 | + |
| 79 | +begin |
| 80 | + ReportMemoryLeaksOnShutdown := True; |
| 81 | + try |
| 82 | + for MethodName in TRegistrar.MethodNames do |
| 83 | + begin |
| 84 | + MethodTitle := 'TArrayUtils.' + MethodName; |
| 85 | + Writeln(MethodTitle); |
| 86 | + Writeln(StringOfChar('=', Length(MethodTitle))); |
| 87 | + Writeln; |
| 88 | + for ProcInfo in TRegistrar.GetProcs(MethodName) do |
| 89 | + begin |
| 90 | + ProcTitle := 'Running ' + ProcInfo.Name; |
| 91 | + Writeln(ProcTitle); |
| 92 | + Writeln(StringOfChar('-', Length(ProcTitle))); |
| 93 | + Writeln; |
| 94 | + // Call procedure |
| 95 | + ProcInfo.Proc; |
| 96 | + Writeln('DONE'); |
| 97 | + Writeln; |
| 98 | + end; |
| 99 | + end; |
| 100 | + except |
| 101 | + on E: Exception do |
| 102 | + Writeln(E.ClassName, ': ', E.Message); |
| 103 | + end; |
| 104 | + Writeln; |
| 105 | + Writeln('END OF DEMO: press enter to exit'); |
| 106 | + Readln; |
| 107 | +end. |
0 commit comments