Skip to content

Commit ff40982

Browse files
Victor MoncadaVictor Moncada
authored andcommitted
updated documentation
1 parent 1d348ec commit ff40982

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Victor Moncada <[email protected]>
3+
Copyright (c) 2025 Victor Moncada <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

docs/algorithm.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Algorithm
2+
`algorithm` is a small module providing a few iterator based algorithms:
3+
4+
- `seq::merge`: similar to `std::merge` but providing a better handling of consecutive ordered values, and has a special case for unbalanced merging (one range is way smaller than the other)
5+
6+
- `seq::inplace_merge`: similar to `std::inplace_merge` but relying on `seq::merge` and using a user-provided buffer. `seq::inplace_merge` never allocates memory unless one of the following constant buffer is provided:
7+
- `seq::default_buffer`: uses as much memory as `std::inplace_merge`
8+
- `seq::medium_buffer`: uses 8 times less memory than with `seq::default_buffer`
9+
- `small_buffer` : uses 32 times less memory than with `seq::default_buffer`
10+
- `tiny_buffer`: uses 128 times less memory than with `seq::default_buffer`
11+
12+
Note that a buffer of size 0 is supported, the algorithm will just be way slower. The inplace merging is based on the following [article](https://www.jmeiners.com/efficient-programming-with-components/15_merge_inplace.html) and was first published in 1981.
13+
14+
- `seq::reverse_descending`: reverse a range sorted in descending order in a stable way: consecutive equal values are not reversed.
15+
16+
- `seq::unique`: removed duplicates from a range in a stable way. This is very similar to `std::unique` except that the range does not need to be sorted. It uses a hash table under the hood to find duplicate values. A custom hash function and comparison function can be passed for custom types.
17+
18+
- `seq::net_sort` and `seq::net_sort_size`: "new" generic stable sorting algorithm that is used everywhere within the seq library. `seq::net_sort` is a merge sort algorithm with the following specificities:
19+
- Bottom-up merging instead of the more traditional top-down approach,
20+
- Small blocks of 8 elements are sorted using a sorting network,
21+
- Bidirectional merging is used for relocatable types,
22+
- Ping-pong merge is used to merge 4 sorted ranges,
23+
- Can work without allocating memory through a (potentially null) user provided buffer,
24+
- Also works on bidirectional iterators.
25+
26+
If provided buffer is one of `seq::default_buffer`, `seq::medium_buffer`, `seq::small_buffer` or `seq::tiny_buffer`, this function will try to allocate memory.
27+
28+
From my tests on multiple input types, net_sort() is always faster than std::stable_sort().
29+
30+
net_sort_size() and net_sort() work on bidirectional iterators. Using net_sort_size() instead of net_sort() is faster when the range size is already known.
31+
32+
Full credits to scandum (https://github.com/scandum) for its quadsort algorithm from which I took several ideas (bidirectional merge and ping-pong merge).

docs/v2.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Library wide changes
2121

2222
- Internal refactoring.
2323
- Updated SEQ_LIKELY/SEQ_UNLIKELY to use c++20 [[likely]]/[[unlikely]] attributes if available.
24-
- Added class `fast_rand`: fasd 32 bits random number generator.
24+
- Added class `fast_rand`: fast 32 bits random number generator.
2525

2626
[hash](hash.md)
2727
--------------------
@@ -67,6 +67,8 @@ Library wide changes
6767
- Internal refactoring and optimizations, huge code simplification.
6868
- Better support of transparent comparison functions.
6969
- Switched from pdqsort to net_sort as sorting algorithm.
70+
- Removed the possibility to modify the underlying tiered_vector container.
71+
- Member functions `tvector()` and `ctvector()` where gathered and renamed in a single const member `container()`
7072
- Added C++23 members extract() and replace()
7173
- [seq::radix_set](radix_tree.md) and `seq::radix_map`:
7274
- Full refactoring to simplify the class.

0 commit comments

Comments
 (0)