@@ -11,25 +11,26 @@ under `src/` directory. The following routines are currently supported:
11
11
12
12
## Sort an array of custom defined class objects (uses ` O(N) ` space)
13
13
``` cpp
14
- template <typename T, typename Func>
15
- void x86simdsort::object_qsort (T * arr, uint32_t arrsize, Func key_func)
14
+ template <typename T, typename U, typename Func>
15
+ void x86simdsort::object_qsort (T * arr, U arrsize, Func key_func)
16
16
```
17
17
`T` is any user defined struct or class and `arr` is a pointer to the first
18
- element in the array of objects of type `T`. `Func` is a lambda function that
19
- computes the `key` value for each object which is the metric used to sort the
20
- objects. `Func` needs to have the following signature:
18
+ element in the array of objects of type `T`. The `arrsize` parameter can be any
19
+ 32-bit or 64-bit integer type. `Func` is a lambda function that computes the
20
+ `key` value for each object which is the metric used to sort the objects.
21
+ `Func` needs to have the following signature:
21
22
22
23
```cpp
23
24
[] (T obj) -> key_t { key_t key; /* compute key for obj */ return key; }
24
25
```
25
26
26
- Note that the return type of the key ` key_t ` needs to be one of the following
27
- : ` [float, uint32_t, int32_t, double, uint64_t, int64_t] ` . ` object_qsort ` has a
28
- space complexity of ` O(N) ` . Specifically, it requires `arrsize *
29
- sizeof(key_t)` bytes to store a vector with all the keys and an additional
30
- ` arrsize * sizeof(uint32_t)` bytes to store the indexes of the object array.
31
- For performance reasons, we support ` object_qsort ` only when the array size is
32
- less than or equal to ` UINT32_MAX ` . An example usage of ` object_qsort ` is
27
+ Note that the return type of the key ` key_t ` needs to be one of the following :
28
+ ` [float, uint32_t, int32_t, double, uint64_t, int64_t] ` . ` object_qsort ` has a
29
+ space complexity of ` O(N) ` . Specifically, it requires ` arrsize * sizeof(key_t) `
30
+ bytes to store a vector with all the keys and an additional `arrsize *
31
+ sizeof(uint32_t)` bytes to store the indexes of the object array. For
32
+ performance reasons, we recommend using ` object_qsort ` when the array size
33
+ is less than or equal to ` UINT32_MAX ` . An example usage of ` object_qsort ` is
33
34
provided in the [ examples] ( #Sort-an-array-of-Points-using-object_qsort )
34
35
section. Refer to [ section] ( #Performance-of-object_qsort ) to get a sense of
35
36
how fast this is relative to ` std::sort ` .
0 commit comments