Skip to content

Commit d96f088

Browse files
author
Raghuveer Devulapalli
committed
update README
1 parent 1891087 commit d96f088

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,26 @@ under `src/` directory. The following routines are currently supported:
1111

1212
## Sort an array of custom defined class objects (uses `O(N)` space)
1313
``` 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)
1616
```
1717
`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:
2122
2223
```cpp
2324
[] (T obj) -> key_t { key_t key; /* compute key for obj */ return key; }
2425
```
2526

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
3334
provided in the [examples](#Sort-an-array-of-Points-using-object_qsort)
3435
section. Refer to [section](#Performance-of-object_qsort) to get a sense of
3536
how fast this is relative to `std::sort`.

0 commit comments

Comments
 (0)