@@ -83,7 +83,7 @@ Private Enum SortDirection
8383 Descending = 2
8484End Enum
8585Private Type SortStruct
86- Value As Variant
86+ value As Variant
8787 SortValue As Variant
8888End Type
8989
@@ -98,7 +98,7 @@ Private This As TThis
9898
9999
100100
101- 'Event executed before the internal array is overwritten
101+ 'Event executed before the internal array is overwritten
102102'@param arr - A reference to this array
103103'@param arr2 - The array which is being assigned to this array
104104Public Event BeforeArrLet(ByRef arr As stdArray , ByRef arr2 As Variant )
@@ -112,7 +112,7 @@ Public Event AfterArrLet(ByRef arr As stdArray, ByRef arr2 As Variant)
112112'@param arr - A the array to which the item is being added
113113'@param iIndex - The index at which the item will be added
114114'@param item - The item which will be added
115- '@param cancel - Set to true to cancel the addition
115+ '@param cancel - Set to true to cancel the addition
116116Public Event BeforeAdd(ByRef arr As stdArray , ByVal iIndex As Long , ByRef item As Variant , ByRef cancel As Boolean )
117117
118118'Event executed after an item is added to the array
@@ -135,7 +135,7 @@ Public Event AfterRemove(ByRef arr As stdArray, ByVal iIndex As Long)
135135
136136'Event executed after an array is cloned
137137'@param clone - A reference to the clone
138- Public Event AfterClone(ByRef clone As stdArray )
138+ Public Event AfterClone(ByRef Clone As stdArray )
139139
140140'Event executed after an array is created
141141'@param arr - A reference to the array
@@ -187,7 +187,7 @@ End Function
187187'Create a `stdArray` object from a VBA array
188188'@constructor
189189'@param arr - Variant array to create a `stdArray` object from.
190- '@returns stdArray<variant> - Returns `stdArray` of variants.
190+ '@returns stdArray<variant> - Returns `stdArray` of variants.
191191Public Function CreateFromArray (ByVal arr As Variant ) As stdArray
192192 Set CreateFromArray = New stdArray
193193
@@ -296,8 +296,8 @@ End Sub
296296
297297
298298'Sort the array
299- '@param cbSortBy as stdICallable<(variant)=>variant> - A mapping function which should map whatever the input is to whatever variant the array should be sorted on.
300- '@param cbComparrason as stdICallable<(variant,variant)=>boolean> - Comparrison function which consumes 2 variants and generates a boolean. See implementation of `Sort_QuickSort` for details.
299+ '@param cbSortBy as stdICallable<(variant)=>variant> - A mapping function which should map whatever the input is to whatever variant the array should be sorted on.
300+ '@param cbComparrason as stdICallable<(variant,variant)=>boolean> - Comparrison function which consumes 2 variants and generates a boolean. See implementation of `Sort_QuickSort` for details.
301301'@param iAlgorithm - Currently only 1 algorithm: 0 - Quicksort
302302'@param bSortInPlace - Sort the array in place. Sorting in-place is prefferred if possible as it is much more performant.
303303'@returns stdArray - A sorted array
@@ -317,7 +317,7 @@ Public Function Sort(Optional ByVal cbSortBy As stdICallable = Nothing, Optional
317317
318318 'Copy array to sort structures
319319 For i = 1 To Length()
320- Call CopyVariant (arr(i).Value , This.BaseArray(i))
320+ Call CopyVariant (arr(i).value , This.BaseArray(i))
321321 If cbSortBy Is Nothing Then
322322 Call CopyVariant (arr(i).SortValue, This.BaseArray(i))
323323 Else
@@ -335,7 +335,7 @@ Public Function Sort(Optional ByVal cbSortBy As stdICallable = Nothing, Optional
335335
336336 'Copy sort structures to array
337337 For i = 1 To Length()
338- Call CopyVariant (This.BaseArray(i), arr(i).Value )
338+ Call CopyVariant (This.BaseArray(i), arr(i).value )
339339 Next
340340
341341 'Return array
@@ -965,10 +965,12 @@ End Function
965965'```
966966Public Function Reduce (ByVal cb As stdICallable , Optional ByVal initialValue As Variant ) As Variant
967967 Dim iStart As Long
968+ Dim el As Variant
968969 If This.Initialised Then
969970 If This.Length > 0 Then
970971 If IsMissing(initialValue) Then
971- Call CopyVariant (Reduce, This.BaseArray(1 ))
972+ CopyVariant el, This.BaseArray(1 )
973+ Call CopyVariant (Reduce, cb.Run(Reduce, el))
972974 iStart = 2
973975 Else
974976 Call CopyVariant (Reduce, initialValue)
@@ -986,7 +988,6 @@ Public Function Reduce(ByVal cb As stdICallable, Optional ByVal initialValue As
986988 Dim i As Long
987989 For i = iStart To This.Length
988990 'BUGFIX: Sometimes required, not sure when
989- Dim el As Variant
990991 CopyVariant el, This.BaseArray(i)
991992
992993 'Reduce
@@ -1054,7 +1055,7 @@ Public Function GroupBy(ByVal cb As stdICallable) As Object
10541055 key = cb.Run(This.BaseArray(i))
10551056
10561057 'If key is not set then set it
1057- If Not result.exists (key) Then Set result(key) = stdArray.Create()
1058+ If Not result.Exists (key) Then Set result(key) = stdArray.Create()
10581059
10591060 'Push item to key
10601061 result(key).Push This.BaseArray(i)
@@ -1083,7 +1084,7 @@ Public Function Max(Optional ByVal cb As stdICallable = Nothing, Optional ByVal
10831084 Call CopyVariant (vtValue, cb.Run(v))
10841085 End If
10851086
1086- 'Compare values and return
1087+ 'Compare values and return
10871088 If IsEmpty(vRet) Then
10881089 Call CopyVariant (vRet, v)
10891090 Call CopyVariant (vMaxValue, vtValue)
@@ -1103,7 +1104,7 @@ End Function
11031104Public Function Min (Optional ByVal cb As stdICallable = Nothing , Optional ByVal startingValue As Variant = Empty ) As Variant
11041105 Dim vRet, vMinValue, v
11051106 vMinValue = startingValue: vRet = startingValue
1106- Dim i as long
1107+ Dim i As Long
11071108 For i = 1 To This.Length
11081109 Call CopyVariant (v, This.BaseArray(i))
11091110
@@ -1115,7 +1116,7 @@ Public Function Min(Optional ByVal cb As stdICallable = Nothing, Optional ByVal
11151116 Call CopyVariant (vtValue, cb.Run(v))
11161117 End If
11171118
1118- 'Compare values and return
1119+ 'Compare values and return
11191120 If IsEmpty(vRet) Then
11201121 Call CopyVariant (vRet, v)
11211122 Call CopyVariant (vMinValue, vtValue)
0 commit comments