@@ -20,13 +20,13 @@ computes the `key` value for each object which is the metric used to sort the
2020objects. `Func` needs to have the following signature:
2121
2222```cpp
23- [] (T obj) -> type_t { type_t key; /* compute key for obj */ return key; }
23+ [] (T obj) -> key_t { key_t key; /* compute key for obj */ return key; }
2424```
2525
26- Note that the return type of the key ` type_t ` needs to be one of the following
26+ Note that the return type of the key ` key_t ` needs to be one of the following
2727: ` [float, uint32_t, int32_t, double, uint64_t, int64_t] ` . ` object_qsort ` has a
2828space complexity of ` O(N) ` . Specifically, it requires `arrsize *
29- sizeof(type_t )` bytes to store a vector with all the keys and an additional
29+ sizeof(key_t )` bytes to store a vector with all the keys and an additional
3030` arrsize * sizeof(uint32_t) ` bytes to store the indexes of the object array.
3131For performance reasons, we support ` object_qsort ` only when the array size is
3232less than or equal to ` UINT32_MAX ` . An example usage of ` object_qsort ` is
@@ -148,14 +148,14 @@ of the custom class and we highly recommend benchmarking before using it. For
148148the sake of illustration, we provide a few examples in
149149[./benchmarks/bench-objsort.hpp](./benchmarks/bench-objsort.hpp) which measures
150150performance of `object_qsort` relative to `std::sort` when sorting an array of
151- points in the cartesian coordinates represented by the class: `struct Point
152- {double x, y, z;}` and ` struct Point {float x, y, x;}`. We sort these points
153- based on several different metrics:
151+ 3D points represented by the class: `struct Point {double x, y, z;}` and
152+ ` struct Point {float x, y, x;}`. We sort these points based on several
153+ different metrics:
154154
155155+ sort by coordinate `x`
156156+ sort by manhanttan distance (relative to origin): `abs(x) + abx(y) + abs(z)`
157157+ sort by Euclidean distance (relative to origin): `sqrt(x*x + y*y + z*z)`
158- + sort by Chebyshev distance (relative to origin): `max(x, y, z )`
158+ + sort by Chebyshev distance (relative to origin): `max(abs(x), abs(y), abs(z) )`
159159
160160The performance data (shown in the plot below) can be collected by building the
161161benchmarks suite and running `./builddir/benchexe --benchmark_filter==*obj*`.
0 commit comments