14 #ifndef TLX_SORT_NETWORKS_BOSE_NELSON_HEADER 15 #define TLX_SORT_NETWORKS_BOSE_NELSON_HEADER 24 namespace sort_networks {
32 namespace bose_nelson {
35 template <
typename Iterator>
37 std::less<typename std::iterator_traits<Iterator>::value_type> >;
42 template <
typename Iterator,
typename CSwap>
43 static inline void merge1_1(Iterator a, Iterator b, CSwap cswap) {
48 template <
typename Iterator,
typename CSwap>
49 static inline void merge1_2(Iterator a, Iterator b, CSwap cswap) {
55 template <
typename Iterator,
typename CSwap>
56 static inline void merge2_1(Iterator a, Iterator b, CSwap cswap) {
62 template <
typename Iterator,
typename CSwap>
63 static inline void merge2_2(Iterator a, Iterator b, CSwap cswap) {
70 template <
typename Iterator,
typename CSwap>
71 static inline void merge2_3(Iterator a, Iterator b, CSwap cswap) {
78 template <
typename Iterator,
typename CSwap>
79 static inline void merge3_2(Iterator a, Iterator b, CSwap cswap) {
86 template <
typename Iterator,
typename CSwap>
87 static inline void merge3_3(Iterator a, Iterator b, CSwap cswap) {
94 template <
typename Iterator,
typename CSwap>
95 static inline void merge3_4(Iterator a, Iterator b, CSwap cswap) {
102 template <
typename Iterator,
typename CSwap>
103 static inline void merge4_3(Iterator a, Iterator b, CSwap cswap) {
110 template <
typename Iterator,
typename CSwap>
111 static inline void merge4_4(Iterator a, Iterator b, CSwap cswap) {
118 template <
typename Iterator,
typename CSwap>
119 static inline void merge4_5(Iterator a, Iterator b, CSwap cswap) {
126 template <
typename Iterator,
typename CSwap>
127 static inline void merge5_5(Iterator a, Iterator b, CSwap cswap) {
134 template <
typename Iterator,
typename CSwap>
135 static inline void merge5_6(Iterator a, Iterator b, CSwap cswap) {
142 template <
typename Iterator,
typename CSwap>
143 static inline void merge6_6(Iterator a, Iterator b, CSwap cswap) {
150 template <
typename Iterator,
typename CSwap>
151 static inline void merge6_7(Iterator a, Iterator b, CSwap cswap) {
158 template <
typename Iterator,
typename CSwap>
159 static inline void merge7_7(Iterator a, Iterator b, CSwap cswap) {
166 template <
typename Iterator,
typename CSwap>
167 static inline void merge7_8(Iterator a, Iterator b, CSwap cswap) {
174 template <
typename Iterator,
typename CSwap>
175 static inline void merge8_8(Iterator a, Iterator b, CSwap cswap) {
184 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
185 static inline void sort2(Iterator a, CSwap cswap = CSwap()) {
190 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
191 static inline void sort3(Iterator a, CSwap cswap = CSwap()) {
197 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
198 static void sort4(Iterator a, CSwap cswap = CSwap()) {
205 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
206 static void sort5(Iterator a, CSwap cswap = CSwap()) {
213 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
214 static void sort6(Iterator a, CSwap cswap = CSwap()) {
221 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
222 static void sort7(Iterator a, CSwap cswap = CSwap()) {
229 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
230 static void sort8(Iterator a, CSwap cswap = CSwap()) {
237 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
238 static void sort9(Iterator a, CSwap cswap = CSwap()) {
245 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
246 static void sort10(Iterator a, CSwap cswap = CSwap()) {
253 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
254 static void sort11(Iterator a, CSwap cswap = CSwap()) {
261 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
262 static void sort12(Iterator a, CSwap cswap = CSwap()) {
269 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
270 static void sort13(Iterator a, CSwap cswap = CSwap()) {
277 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
278 static void sort14(Iterator a, CSwap cswap = CSwap()) {
285 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
286 static void sort15(Iterator a, CSwap cswap = CSwap()) {
293 template <
typename Iterator,
typename CSwap = DefaultCSwap<Iterator> >
294 static void sort16(Iterator a, CSwap cswap = CSwap()) {
304 template <
typename Iterator,
typename Comparator =
305 std::less<typename std::iterator_traits<Iterator>::value_type> >
306 static void sort(Iterator begin, Iterator end, Comparator cmp = Comparator()) {
309 switch (end - begin) {
375 #endif // !TLX_SORT_NETWORKS_BOSE_NELSON_HEADER
static void merge3_2(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length three and two
static void merge2_3(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length two and three
static void merge7_7(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length seven and seven
static void merge3_3(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length three and three
static void merge2_2(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length two and two
static void merge8_8(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length eight and eight
static void sort(Iterator begin, Iterator end, Comparator cmp=Comparator())
Call Bose-Network sorting network for up to sixteen elements with given comparison method...
static void merge4_5(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length four and five
static void sort2(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for two elements.
static void sort7(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for seven elements.
static void merge7_8(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length seven and eight
static void merge4_4(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length four and four
static void merge3_4(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length three and four
static void merge6_6(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length six and six
static void merge1_2(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length one and two
static void merge1_1(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length one and one
static void sort9(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for nine elements.
Conditional swap implementation used for sorting networks: trivial portable C++ implementation with c...
static void merge5_5(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length five and five
static void sort15(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for fifteen elements.
static void sort5(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for five elements.
static void sort14(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for fourteen elements.
static void sort10(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for ten elements.
static void merge2_1(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length two and one
static void merge6_7(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length six and seven
static void sort11(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for eleven elements.
static void sort6(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for six elements.
static void sort13(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for thirteen elements.
static void merge5_6(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length five and six
static void sort12(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for twelve elements.
static void sort4(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for four elements.
static void sort16(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for sixteen elements.
static void sort8(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for eight elements.
static void sort3(Iterator a, CSwap cswap=CSwap())
Bose-Nelson sorting network for three elements.
static void merge4_3(Iterator a, Iterator b, CSwap cswap)
merge network for element arrays length four and three