@lpc-lang/core 1.1.49 → 1.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/efuns/fluffos/arrays.h +58 -6
package/package.json
CHANGED
|
@@ -76,21 +76,38 @@ varargs <mixed*>* unique_array(mixed *arr, function f, mixed skip );
|
|
|
76
76
|
* that the array must be homogeneous, composed entirely of a single type,
|
|
77
77
|
* where that type is string, int, or float. Arrays of arrays are sorted
|
|
78
78
|
* by sorting based on the first element, making database sorts possible.
|
|
79
|
-
* @template
|
|
80
|
-
* @param {T} arr The array to sort
|
|
81
|
-
* @returns {T} The sorted array
|
|
79
|
+
* @template T
|
|
80
|
+
* @param {T*} arr The array to sort
|
|
81
|
+
* @returns {T*} The sorted array
|
|
82
82
|
*/
|
|
83
83
|
mixed *sort_array( mixed *arr, string fun, object ob, mixed extra... );
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* sort_array() - sort an array using a function pointer to compare elements.
|
|
87
|
+
*
|
|
88
|
+
* @template T
|
|
89
|
+
* @param {T*} arr The array to sort
|
|
90
|
+
* @returns {T*} The sorted array
|
|
91
|
+
*/
|
|
84
92
|
mixed *sort_array( mixed *arr, function f, mixed extra... );
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* sort_array() - sort an array using the built-in sort routines. A 'direction'
|
|
96
|
+
* of 1 or 0 sorts in ascending order, -1 in descending order.
|
|
97
|
+
*
|
|
98
|
+
* @template T
|
|
99
|
+
* @param {T*} arr The array to sort
|
|
100
|
+
* @returns {T*} The sorted array
|
|
101
|
+
*/
|
|
85
102
|
mixed *sort_array( mixed *arr, int direction );
|
|
86
103
|
|
|
87
104
|
/**
|
|
88
105
|
* shuffle() - Rearrange the elements in the array in random order
|
|
89
106
|
*
|
|
90
107
|
* Shuffle the array and return.
|
|
91
|
-
* @template
|
|
92
|
-
* @param {T} arr The array to shuffle
|
|
93
|
-
* @returns {T} The shuffled array
|
|
108
|
+
* @template T
|
|
109
|
+
* @param {T*} arr The array to shuffle
|
|
110
|
+
* @returns {T*} The shuffled array
|
|
94
111
|
*/
|
|
95
112
|
mixed *shuffle(mixed *arr);
|
|
96
113
|
|
|
@@ -153,6 +170,27 @@ varargs int member_array( mixed item, mixed * | string arr, void | int start );
|
|
|
153
170
|
*
|
|
154
171
|
*/
|
|
155
172
|
mixed *map_array( mixed *arr, string fun, object ob, mixed extra... );
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @template T, Y
|
|
176
|
+
* @callback mapArrayCallback
|
|
177
|
+
* @param {T} element The element being mapped
|
|
178
|
+
* @returns {Y} The replacement for that element
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* map_array() - modify an array of elements via application of a function pointer.
|
|
183
|
+
*
|
|
184
|
+
* The result holds whatever 'f' returns, so mapping a `string*` through a callback
|
|
185
|
+
* returning an int yields an `int*`. The `ob->fun()` form above cannot be typed this
|
|
186
|
+
* way -- the function is named by a string, so its return type is not knowable -- and
|
|
187
|
+
* stays `mixed*`.
|
|
188
|
+
*
|
|
189
|
+
* @template T, Y
|
|
190
|
+
* @param {T*} arr The array to map
|
|
191
|
+
* @param {mapArrayCallback<T,Y>} f The function applied to each element
|
|
192
|
+
* @returns {Y*} The mapped array
|
|
193
|
+
*/
|
|
156
194
|
mixed *map_array( mixed *arr, function f, mixed extra... );
|
|
157
195
|
|
|
158
196
|
/**
|
|
@@ -169,6 +207,20 @@ mixed *map_array( mixed *arr, function f, mixed extra... );
|
|
|
169
207
|
*
|
|
170
208
|
*/
|
|
171
209
|
mixed *filter_array( mixed *arr, string fun, object|string ob, mixed extra... );
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* filter_array() - return a selective sub-array using a function pointer.
|
|
213
|
+
*
|
|
214
|
+
* Unlike map_array(), filtering selects elements rather than transforming them, so the
|
|
215
|
+
* result holds the same element type as the input -- the callback's return value is only
|
|
216
|
+
* the keep-or-discard test. The `ob->fun()` form above cannot be typed this way and stays
|
|
217
|
+
* `mixed*`.
|
|
218
|
+
*
|
|
219
|
+
* @template T
|
|
220
|
+
* @param {T*} arr The array to filter
|
|
221
|
+
* @param {filterCallback<T>} f Nonzero to keep the element, zero to discard it
|
|
222
|
+
* @returns {T*} The elements that passed the test
|
|
223
|
+
*/
|
|
172
224
|
mixed *filter_array( mixed *arr, function f, mixed extra... );
|
|
173
225
|
|
|
174
226
|
/**
|