From 7708d2d54b5e1da418cb196d3c5e083feedd947e Mon Sep 17 00:00:00 2001 From: Francisco Tapia Date: Tue, 29 Apr 2025 08:55:44 +0200 Subject: [PATCH] Correction of the error with and or not --- .../parallel/runCLANG_benchmark_numbers.sh | 4 +- .../parallel/runCLANG_benchmark_objects.sh | 4 +- .../parallel/runCLANG_benchmark_strings.sh | 4 +- .../parallel/runGCC_benchmark_numbers.sh | 4 +- .../parallel/runGCC_benchmark_objects.sh | 4 +- .../parallel/runGCC_benchmark_strings.sh | 4 +- .../single/runCLANG_benchmark_numbers.sh | 4 +- .../single/runCLANG_benchmark_objects.sh | 4 +- .../single/runCLANG_benchmark_strings.sh | 4 +- benchmark/single/runGCC_benchmark_numbers.sh | 4 +- benchmark/single/runGCC_benchmark_objects.sh | 4 +- benchmark/single/runGCC_benchmark_strings.sh | 4 +- .../blk_detail/backbone.hpp | 1 - .../block_indirect_sort/blk_detail/block.hpp | 2 +- .../blk_detail/merge_blocks.hpp | 21 +- .../blk_detail/move_blocks.hpp | 7 +- .../blk_detail/parallel_sort.hpp | 13 +- .../block_indirect_sort.hpp | 11 +- include/boost/sort/common/deque_cnc.hpp | 1 - include/boost/sort/common/file_vector.hpp | 3 +- include/boost/sort/common/indirect.hpp | 2 +- include/boost/sort/common/int_array.hpp | 1 - include/boost/sort/common/merge_block.hpp | 2 +- include/boost/sort/common/merge_four.hpp | 15 +- include/boost/sort/common/merge_vector.hpp | 2 - include/boost/sort/common/pivot.hpp | 1 - include/boost/sort/common/scheduler.hpp | 3 +- include/boost/sort/common/spinlock.hpp | 1 - include/boost/sort/common/stack_cnc.hpp | 1 - include/boost/sort/common/time_measure.hpp | 1 - include/boost/sort/common/util/algorithm.hpp | 2 +- include/boost/sort/common/util/atomic.hpp | 2 +- .../sort/common/util/circular_buffer.hpp | 1 - include/boost/sort/common/util/insert.hpp | 2 - include/boost/sort/common/util/search.hpp | 238 +----------------- include/boost/sort/common/util/traits.hpp | 1 - .../parallel_stable_sort.hpp | 7 +- .../boost/sort/sample_sort/sample_sort.hpp | 13 +- include/boost/sort/spinsort/spinsort.hpp | 14 +- test/test_block_indirect_sort.cpp | 3 +- test/test_flat_stable_sort.cpp | 5 +- test/test_insert_sort.cpp | 7 +- test/test_parallel_stable_sort.cpp | 8 +- test/test_sample_sort.cpp | 7 +- test/test_spinsort.cpp | 5 +- 45 files changed, 95 insertions(+), 356 deletions(-) diff --git a/benchmark/parallel/runCLANG_benchmark_numbers.sh b/benchmark/parallel/runCLANG_benchmark_numbers.sh index 96a7904..1e3831f 100755 --- a/benchmark/parallel/runCLANG_benchmark_numbers.sh +++ b/benchmark/parallel/runCLANG_benchmark_numbers.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." echo "." -clang++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +clang++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -clang++ ./benchmark_numbers.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_numbers +clang++ ./benchmark_numbers.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_numbers echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 10 minutes depending of your machine )" diff --git a/benchmark/parallel/runCLANG_benchmark_objects.sh b/benchmark/parallel/runCLANG_benchmark_objects.sh index 688b68e..fcfab0e 100755 --- a/benchmark/parallel/runCLANG_benchmark_objects.sh +++ b/benchmark/parallel/runCLANG_benchmark_objects.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." -clang++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +clang++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -clang++ ./benchmark_objects.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_objects +clang++ ./benchmark_objects.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_objects echo "." echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 60 minutes depending of your machine )" diff --git a/benchmark/parallel/runCLANG_benchmark_strings.sh b/benchmark/parallel/runCLANG_benchmark_strings.sh index 0875bf8..c0ae926 100755 --- a/benchmark/parallel/runCLANG_benchmark_strings.sh +++ b/benchmark/parallel/runCLANG_benchmark_strings.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." echo "." -g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -g++ ./benchmark_strings.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_strings +g++ ./benchmark_strings.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_strings echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 10 minutes depending of your machine )" diff --git a/benchmark/parallel/runGCC_benchmark_numbers.sh b/benchmark/parallel/runGCC_benchmark_numbers.sh index a667ea3..abf4457 100755 --- a/benchmark/parallel/runGCC_benchmark_numbers.sh +++ b/benchmark/parallel/runGCC_benchmark_numbers.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." echo "." -g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -g++ ./benchmark_numbers.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_numbers +g++ ./benchmark_numbers.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_numbers echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 10 minutes depending of your machine )" diff --git a/benchmark/parallel/runGCC_benchmark_objects.sh b/benchmark/parallel/runGCC_benchmark_objects.sh index f9198a8..f609f77 100755 --- a/benchmark/parallel/runGCC_benchmark_objects.sh +++ b/benchmark/parallel/runGCC_benchmark_objects.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." -g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -g++ ./benchmark_objects.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_objects +g++ ./benchmark_objects.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_objects echo "." echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 60 minutes depending of your machine )" diff --git a/benchmark/parallel/runGCC_benchmark_strings.sh b/benchmark/parallel/runGCC_benchmark_strings.sh index 0875bf8..86926ae 100755 --- a/benchmark/parallel/runGCC_benchmark_strings.sh +++ b/benchmark/parallel/runGCC_benchmark_strings.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." echo "." -g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -g++ ./benchmark_strings.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_strings +g++ ./benchmark_strings.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -pthread -s -lpthread -o benchmark_strings echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 10 minutes depending of your machine )" diff --git a/benchmark/single/runCLANG_benchmark_numbers.sh b/benchmark/single/runCLANG_benchmark_numbers.sh index 10ac6f6..2fbf07f 100755 --- a/benchmark/single/runCLANG_benchmark_numbers.sh +++ b/benchmark/single/runCLANG_benchmark_numbers.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." echo "." -clang++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +clang++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -clang++ ./benchmark_numbers.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o benchmark_numbers +clang++ ./benchmark_numbers.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o benchmark_numbers echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 10 minutes depending of your machine )" diff --git a/benchmark/single/runCLANG_benchmark_objects.sh b/benchmark/single/runCLANG_benchmark_objects.sh index 4526072..0f41114 100755 --- a/benchmark/single/runCLANG_benchmark_objects.sh +++ b/benchmark/single/runCLANG_benchmark_objects.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." -clang++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +clang++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -clang++ ./benchmark_objects.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o benchmark_objects +clang++ ./benchmark_objects.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o benchmark_objects echo "." echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 45 minutes depending of your machine )" diff --git a/benchmark/single/runCLANG_benchmark_strings.sh b/benchmark/single/runCLANG_benchmark_strings.sh index 3d064f2..414b09d 100755 --- a/benchmark/single/runCLANG_benchmark_strings.sh +++ b/benchmark/single/runCLANG_benchmark_strings.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." echo "." -clang++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +clang++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -clang++ ./benchmark_strings.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o benchmark_strings +clang++ ./benchmark_strings.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o benchmark_strings echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 10 minutes depending of your machine )" diff --git a/benchmark/single/runGCC_benchmark_numbers.sh b/benchmark/single/runGCC_benchmark_numbers.sh index 36e9941..3f04ab2 100755 --- a/benchmark/single/runGCC_benchmark_numbers.sh +++ b/benchmark/single/runGCC_benchmark_numbers.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." echo "." -g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -g++ ./benchmark_numbers.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o benchmark_numbers +g++ ./benchmark_numbers.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o benchmark_numbers echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 10 minutes depending of your machine )" diff --git a/benchmark/single/runGCC_benchmark_objects.sh b/benchmark/single/runGCC_benchmark_objects.sh index 5c71bf0..b0037cf 100755 --- a/benchmark/single/runGCC_benchmark_objects.sh +++ b/benchmark/single/runGCC_benchmark_objects.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." -g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -g++ ./benchmark_objects.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o benchmark_objects +g++ ./benchmark_objects.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o benchmark_objects echo "." echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 45 minutes depending of your machine )" diff --git a/benchmark/single/runGCC_benchmark_strings.sh b/benchmark/single/runGCC_benchmark_strings.sh index 53b3bf6..ad7e6bb 100755 --- a/benchmark/single/runGCC_benchmark_strings.sh +++ b/benchmark/single/runGCC_benchmark_strings.sh @@ -7,9 +7,9 @@ echo "==================================================================" echo "." echo "C O M P I L I N G . . . . . . . . . . ." echo "." -g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o file_generator +g++ ./file_generator.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o file_generator -g++ ./benchmark_strings.cpp -std=c++11 -march=native -w -fno-exceptions -fno-operator-names -O3 -I../../include -s -o benchmark_strings +g++ ./benchmark_strings.cpp -std=c++11 -march=native -w -fno-operator-names -O3 -I../../include -s -o benchmark_strings echo "R U N N I N G . . . . . . . . . . ." echo "( The time needed is around 10 minutes depending of your machine )" diff --git a/include/boost/sort/block_indirect_sort/blk_detail/backbone.hpp b/include/boost/sort/block_indirect_sort/blk_detail/backbone.hpp index 19e7f94..9a3bb35 100644 --- a/include/boost/sort/block_indirect_sort/blk_detail/backbone.hpp +++ b/include/boost/sort/block_indirect_sort/blk_detail/backbone.hpp @@ -14,7 +14,6 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_BACKBONE_HPP #define __BOOST_SORT_PARALLEL_DETAIL_BACKBONE_HPP -#include #include #include #include diff --git a/include/boost/sort/block_indirect_sort/blk_detail/block.hpp b/include/boost/sort/block_indirect_sort/blk_detail/block.hpp index b9a353e..cade7bf 100644 --- a/include/boost/sort/block_indirect_sort/blk_detail/block.hpp +++ b/include/boost/sort/block_indirect_sort/blk_detail/block.hpp @@ -14,7 +14,7 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_BLOCK_HPP #define __BOOST_SORT_PARALLEL_DETAIL_BLOCK_HPP -#include + #include namespace boost diff --git a/include/boost/sort/block_indirect_sort/blk_detail/merge_blocks.hpp b/include/boost/sort/block_indirect_sort/blk_detail/merge_blocks.hpp index 0517401..677acc3 100644 --- a/include/boost/sort/block_indirect_sort/blk_detail/merge_blocks.hpp +++ b/include/boost/sort/block_indirect_sort/blk_detail/merge_blocks.hpp @@ -14,7 +14,6 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_MERGE_BLOCKS_HPP #define __BOOST_SORT_PARALLEL_DETAIL_MERGE_BLOCKS_HPP -#include #include #include #include @@ -99,7 +98,7 @@ struct merge_blocks bscu::atomic_add(counter, 1); function_t f1 = [this, rng_input, &counter, &error]( ) -> void { - if (not error) + if (! error) { try { @@ -134,7 +133,7 @@ struct merge_blocks bscu::atomic_add(counter, 1); function_t f1 = [this, rng_input, &counter, &error]( ) -> void { - if (not error) + if (! error) { try { @@ -183,7 +182,7 @@ merge_blocks { size_t nblock1 = pos_index2 - pos_index1; size_t nblock2 = pos_index3 - pos_index2; - if (nblock1 == 0 or nblock2 == 0) return; + if (nblock1 == 0 || nblock2 == 0) return; //----------------------------------------------------------------------- // Merging of the two intervals @@ -205,7 +204,7 @@ merge_blocks // tail process //------------------------------------------------------------------- if (vpos2.back().pos() == (bk.nblock - 1) - and bk.range_tail.first != bk.range_tail.last) + && bk.range_tail.first != bk.range_tail.last) { tail_process(vpos1, vpos2); nblock1 = vpos1.size(); @@ -236,7 +235,7 @@ void merge_blocks ::tail_process( std::vector &vblkpos1, std::vector &vblkpos2 ) { - if (vblkpos1.size() == 0 or vblkpos2.size() == 0) return; + if (vblkpos1.size() == 0 || vblkpos2.size() == 0) return; vblkpos2.pop_back(); @@ -291,7 +290,7 @@ void merge_blocks { size_t pos = pos_ini + size_part; while (pos < pos_last - and bk.index[pos - 1].side() == bk.index[pos].side()) + && bk.index[pos - 1].side() == bk.index[pos].side()) { ++pos; } @@ -377,16 +376,16 @@ void merge_blocks bool final = (posx == range_input.last); bool mergeable = false; - if (not final) + if (! final) { bp_posx = bk.index[posx]; rng_posx = bk.get_range(bp_posx.pos()); side_posx = bp_posx.side(); mergeable = (side_max != side_posx - and is_mergeable(rng_max, rng_posx, bk.cmp)); + && is_mergeable(rng_max, rng_posx, bk.cmp)); } if (bk.error) return; - if (final or not mergeable) + if (final || ! mergeable) { range_pos rp_final(posx_ini, posx); if (rp_final.size() > 1) @@ -401,7 +400,7 @@ void merge_blocks } } posx_ini = posx; - if (not final) + if (! final) { rng_max = rng_posx; side_max = side_posx; diff --git a/include/boost/sort/block_indirect_sort/blk_detail/move_blocks.hpp b/include/boost/sort/block_indirect_sort/blk_detail/move_blocks.hpp index 5ed8f41..a375468 100644 --- a/include/boost/sort/block_indirect_sort/blk_detail/move_blocks.hpp +++ b/include/boost/sort/block_indirect_sort/blk_detail/move_blocks.hpp @@ -15,7 +15,6 @@ #define __BOOST_SORT_PARALLEL_DETAIL_MOVE_BLOCKS_HPP #include -#include #include #include #include @@ -86,7 +85,7 @@ struct move_blocks bscu::atomic_add(counter, 1); function_t f1 = [this, sequence, &counter, &error]( ) -> void { - if (not error) + if (! error) { try { @@ -121,7 +120,7 @@ struct move_blocks bscu::atomic_add(counter, 1); function_t f1 = [this, sequence, &counter, &error]( ) -> void { - if (not error) + if (! error) { try { @@ -169,7 +168,7 @@ move_blocks while (pos_index_ini < bk.index.size()) { while (pos_index_ini < bk.index.size() - and bk.index[pos_index_ini].pos() == pos_index_ini) + && bk.index[pos_index_ini].pos() == pos_index_ini) { ++pos_index_ini; } diff --git a/include/boost/sort/block_indirect_sort/blk_detail/parallel_sort.hpp b/include/boost/sort/block_indirect_sort/blk_detail/parallel_sort.hpp index afb7606..22836e9 100644 --- a/include/boost/sort/block_indirect_sort/blk_detail/parallel_sort.hpp +++ b/include/boost/sort/block_indirect_sort/blk_detail/parallel_sort.hpp @@ -14,7 +14,6 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_PARALLEL_SORT_HPP #define __BOOST_SORT_PARALLEL_DETAIL_PARALLEL_SORT_HPP -#include #include #include #include @@ -94,7 +93,7 @@ struct parallel_sort bscu::atomic_add(counter, 1); function_t f1 = [this, first, last, level, &counter, &error]( ) { - if (not error) + if (! error) { try { @@ -141,13 +140,13 @@ parallel_sort //------------------- check if sort -------------------------------------- bool sorted = true; for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sorted = not bk.cmp(*it2, *it1)); it1 = it2++); + it2 != last && (sorted = ! bk.cmp(*it2, *it1)); it1 = it2++); if (sorted) return; //------------------- check if reverse sort --------------------------- sorted = true; for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sorted = not bk.cmp(*it1, *it2)); it1 = it2++); + it2 != last && (sorted = ! bk.cmp(*it1, *it2)); it1 = it2++); if (sorted) { @@ -171,7 +170,7 @@ parallel_sort pdqsort(first, last, bk.cmp); return; } - if (not bk.error) divide_sort(first, last, level); + if (! bk.error) divide_sort(first, last, level); // wait until all the parts are finished bk.exec(counter); @@ -193,12 +192,12 @@ void parallel_sort //------------------- check if sort ----------------------------------- bool sorted = true; for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sorted = not bk.cmp(*it2, *it1)); it1 = it2++); + it2 != last && (sorted = ! bk.cmp(*it2, *it1)); it1 = it2++); if (sorted) return; //---------------- check if finish the subdivision ------------------- size_t nelem = last - first; - if (level == 0 or nelem < (max_per_thread)) + if (level == 0 || nelem < (max_per_thread)) { return pdqsort(first, last, bk.cmp); } diff --git a/include/boost/sort/block_indirect_sort/block_indirect_sort.hpp b/include/boost/sort/block_indirect_sort/block_indirect_sort.hpp index 331e7a6..462cab6 100644 --- a/include/boost/sort/block_indirect_sort/block_indirect_sort.hpp +++ b/include/boost/sort/block_indirect_sort/block_indirect_sort.hpp @@ -13,7 +13,6 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_BLOCK_INDIRECT_SORT_HPP #define __BOOST_SORT_PARALLEL_DETAIL_BLOCK_INDIRECT_SORT_HPP -#include #include #include #include @@ -201,14 +200,14 @@ block_indirect_sort //------------------- check if sort ----------------------------------- bool sorted = true; - for (Iter_t it1 = first, it2 = first + 1; it2 != last and (sorted = - not bk.cmp(*it2, *it1)); it1 = it2++); + for (Iter_t it1 = first, it2 = first + 1; it2 != last && (sorted = + ! bk.cmp(*it2, *it1)); it1 = it2++); if (sorted) return; //------------------- check if reverse sort --------------------------- sorted = true; - for (Iter_t it1 = first, it2 = first + 1; it2 != last and (sorted = - not bk.cmp(*it1, *it2)); it1 = it2++); + for (Iter_t it1 = first, it2 = first + 1; it2 != last && (sorted = + ! bk.cmp(*it1, *it2)); it1 = it2++); if (sorted) { @@ -230,7 +229,7 @@ block_indirect_sort if (nbits_size > 5) nbits_size = 5; size_t max_per_thread = (size_t) 1 << (18 - nbits_size); - if (nelem < (max_per_thread) or nthread < 2) + if (nelem < (max_per_thread) || nthread < 2) { //intro_sort (first, last, bk.cmp); pdqsort(first, last, bk.cmp); diff --git a/include/boost/sort/common/deque_cnc.hpp b/include/boost/sort/common/deque_cnc.hpp index 8445d50..1d93d00 100644 --- a/include/boost/sort/common/deque_cnc.hpp +++ b/include/boost/sort/common/deque_cnc.hpp @@ -14,7 +14,6 @@ #ifndef __TOOLS_DEQUE_CNC_HPP #define __TOOLS_DEQUE_CNC_HPP -#include #include #include #include diff --git a/include/boost/sort/common/file_vector.hpp b/include/boost/sort/common/file_vector.hpp index 642ccf3..de5f772 100644 --- a/include/boost/sort/common/file_vector.hpp +++ b/include/boost/sort/common/file_vector.hpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -230,7 +229,7 @@ struct uint64_file_generator { //---------------------------- begin --------------------------------- s = filename; input.open(filename, std::ios_base::in | std::ios_base::binary); - if (input.fail() or input.bad()) + if (input.fail() || input.bad()) { throw std::ios_base::failure("could not open file \n"); }; diff --git a/include/boost/sort/common/indirect.hpp b/include/boost/sort/common/indirect.hpp index bc1a8f2..5ac8d5b 100644 --- a/include/boost/sort/common/indirect.hpp +++ b/include/boost/sort/common/indirect.hpp @@ -13,7 +13,7 @@ #ifndef __BOOST_SORT_PARALLEL_COMMON_INDIRECT_HPP #define __BOOST_SORT_PARALLEL_COMMON_INDIRECT_HPP -//#include + #include #include #include diff --git a/include/boost/sort/common/int_array.hpp b/include/boost/sort/common/int_array.hpp index dfc339b..22c3b0c 100644 --- a/include/boost/sort/common/int_array.hpp +++ b/include/boost/sort/common/int_array.hpp @@ -15,7 +15,6 @@ #ifndef __BOOST_SORT_COMMON_INT_ARRAY_HPP #define __BOOST_SORT_COMMON_INT_ARRAY_HPP -#include #include #include diff --git a/include/boost/sort/common/merge_block.hpp b/include/boost/sort/common/merge_block.hpp index 47cf6be..976e3af 100644 --- a/include/boost/sort/common/merge_block.hpp +++ b/include/boost/sort/common/merge_block.hpp @@ -315,7 +315,7 @@ void merge_block { // The list B is finished rngA = get_range(*itxA); if (ntail != 0 && indexB.back() == (nblock - 1)) // exist tail - { // add the tail block to indexA, and shift the element + { // add the tail block to indexA, && shift the element indexA.push_back(indexB.back()); size_t numA = size_t(itA - rngA.first); ptr_circ->pop_move_back(rngA.first, numA); diff --git a/include/boost/sort/common/merge_four.hpp b/include/boost/sort/common/merge_four.hpp index 50cff80..d796ffb 100644 --- a/include/boost/sort/common/merge_four.hpp +++ b/include/boost/sort/common/merge_four.hpp @@ -13,7 +13,6 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_UTIL_MERGE_FOUR_HPP #define __BOOST_SORT_PARALLEL_DETAIL_UTIL_MERGE_FOUR_HPP -#include #include #include #include @@ -56,7 +55,7 @@ inline bool less_range(Iter_t it1, uint32_t pos1, Iter_t it2, uint32_t pos2, Compare comp = Compare()) { return (comp(*it1, *it2)) ? true : - (pos2 < pos1) ? false : not (comp(*it2, *it1)); + (pos2 < pos1) ? false : ! (comp(*it2, *it1)); } //----------------------------------------------------------------------------- @@ -123,7 +122,7 @@ range full_merge4(const range &rdest, { swap(pos[0], pos[1]); } - if (npos == 4 and less_range(vrange_input[pos[3]].first, pos[3], + if (npos == 4 && less_range(vrange_input[pos[3]].first, pos[3], vrange_input[pos[2]].first, pos[2], comp)) { swap(pos[3], pos[2]); @@ -134,7 +133,7 @@ range full_merge4(const range &rdest, swap(pos[0], pos[2]); }; if (npos == 4 - and less_range (vrange_input[pos[3]].first, pos[3], + && less_range (vrange_input[pos[3]].first, pos[3], vrange_input[pos[1]].first, pos[1], comp)) { swap(pos[1], pos[3]); @@ -167,7 +166,7 @@ range full_merge4(const range &rdest, { swap(pos[1], pos[2]); if (npos == 4 - and less_range(vrange_input[pos[3]].first, + && less_range(vrange_input[pos[3]].first, pos[3], vrange_input[pos[2]].first, pos[2], comp)) @@ -252,7 +251,7 @@ range uninit_full_merge4(const range &dest, { swap(pos[0], pos[1]); }; - if (npos == 4 and less_range(vrange_input[pos[3]].first, pos[3], + if (npos == 4 && less_range(vrange_input[pos[3]].first, pos[3], vrange_input[pos[2]].first, pos[2], comp)) { swap(pos[3], pos[2]); @@ -262,7 +261,7 @@ range uninit_full_merge4(const range &dest, { swap(pos[0], pos[2]); }; - if (npos == 4 and less_range(vrange_input[pos[3]].first, pos[3], + if (npos == 4 && less_range(vrange_input[pos[3]].first, pos[3], vrange_input[pos[1]].first, pos[1], comp)) { swap(pos[1], pos[3]); @@ -295,7 +294,7 @@ range uninit_full_merge4(const range &dest, vrange_input[pos[1]].first, pos[1], comp)) { swap(pos[1], pos[2]); - if (npos == 4 and less_range(vrange_input[pos[3]].first, + if (npos == 4 && less_range(vrange_input[pos[3]].first, pos[3], vrange_input[pos[2]].first, pos[2], comp)) diff --git a/include/boost/sort/common/merge_vector.hpp b/include/boost/sort/common/merge_vector.hpp index 1657455..697a9a1 100644 --- a/include/boost/sort/common/merge_vector.hpp +++ b/include/boost/sort/common/merge_vector.hpp @@ -14,8 +14,6 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_UTIL_MERGE_VECTOR_HPP #define __BOOST_SORT_PARALLEL_DETAIL_UTIL_MERGE_VECTOR_HPP - -#include #include #include #include diff --git a/include/boost/sort/common/pivot.hpp b/include/boost/sort/common/pivot.hpp index 33ada27..865576d 100644 --- a/include/boost/sort/common/pivot.hpp +++ b/include/boost/sort/common/pivot.hpp @@ -13,7 +13,6 @@ #ifndef __BOOST_SORT_COMMON_PIVOT_HPP #define __BOOST_SORT_COMMON_PIVOT_HPP -#include #include namespace boost diff --git a/include/boost/sort/common/scheduler.hpp b/include/boost/sort/common/scheduler.hpp index 6e54db8..6760bc4 100644 --- a/include/boost/sort/common/scheduler.hpp +++ b/include/boost/sort/common/scheduler.hpp @@ -14,7 +14,6 @@ #ifndef __BOOST_SORT_COMMON_SCHEDULER_HPP #define __BOOST_SORT_COMMON_SCHEDULER_HPP -#include #include #include #include @@ -232,7 +231,7 @@ struct scheduler if (nelem == 0) return false; key_t th_id = std::this_thread::get_id(); it_map itmp = mp.find(th_id); - if (itmp != mp.end() and not itmp->second.empty()) + if (itmp != mp.end() && ! itmp->second.empty()) { f = std::move(itmp->second.back()); itmp->second.pop_back(); diff --git a/include/boost/sort/common/spinlock.hpp b/include/boost/sort/common/spinlock.hpp index d88796b..9dabe4a 100644 --- a/include/boost/sort/common/spinlock.hpp +++ b/include/boost/sort/common/spinlock.hpp @@ -13,7 +13,6 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_UTIL_SPINLOCK_HPP #define __BOOST_SORT_PARALLEL_DETAIL_UTIL_SPINLOCK_HPP -#include #include #include #include diff --git a/include/boost/sort/common/stack_cnc.hpp b/include/boost/sort/common/stack_cnc.hpp index 0121b74..c3827b0 100644 --- a/include/boost/sort/common/stack_cnc.hpp +++ b/include/boost/sort/common/stack_cnc.hpp @@ -13,7 +13,6 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_UTIL_STACK_CNC_HPP #define __BOOST_SORT_PARALLEL_DETAIL_UTIL_STACK_CNC_HPP -#include #include #include diff --git a/include/boost/sort/common/time_measure.hpp b/include/boost/sort/common/time_measure.hpp index ab25005..64b363b 100644 --- a/include/boost/sort/common/time_measure.hpp +++ b/include/boost/sort/common/time_measure.hpp @@ -14,7 +14,6 @@ #ifndef __BOOST_SORT_PARALLEL_TOOLS_TIME_MEASURE_HPP #define __BOOST_SORT_PARALLEL_TOOLS_TIME_MEASURE_HPP -#include #include namespace boost diff --git a/include/boost/sort/common/util/algorithm.hpp b/include/boost/sort/common/util/algorithm.hpp index d14fa8f..3711cce 100644 --- a/include/boost/sort/common/util/algorithm.hpp +++ b/include/boost/sort/common/util/algorithm.hpp @@ -13,7 +13,7 @@ #ifndef __BOOST_SORT_COMMON_UTIL_ALGORITHM_HPP #define __BOOST_SORT_COMMON_UTIL_ALGORITHM_HPP -#include + #include #include #include diff --git a/include/boost/sort/common/util/atomic.hpp b/include/boost/sort/common/util/atomic.hpp index ac5d5b4..6dcc388 100644 --- a/include/boost/sort/common/util/atomic.hpp +++ b/include/boost/sort/common/util/atomic.hpp @@ -12,7 +12,7 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_UTIL_ATOMIC_HPP #define __BOOST_SORT_PARALLEL_DETAIL_UTIL_ATOMIC_HPP -#include + #include #include #include diff --git a/include/boost/sort/common/util/circular_buffer.hpp b/include/boost/sort/common/util/circular_buffer.hpp index a1471d3..6fac423 100644 --- a/include/boost/sort/common/util/circular_buffer.hpp +++ b/include/boost/sort/common/util/circular_buffer.hpp @@ -13,7 +13,6 @@ #ifndef __BOOST_SORT_COMMON_UTIL_CIRCULAR_BUFFER_HPP #define __BOOST_SORT_COMMON_UTIL_CIRCULAR_BUFFER_HPP -#include #include #include #include diff --git a/include/boost/sort/common/util/insert.hpp b/include/boost/sort/common/util/insert.hpp index 451741c..e3e7af5 100644 --- a/include/boost/sort/common/util/insert.hpp +++ b/include/boost/sort/common/util/insert.hpp @@ -13,8 +13,6 @@ #ifndef __BOOST_SORT_COMMON_UTIL_INSERT_HPP #define __BOOST_SORT_COMMON_UTIL_INSERT_HPP - -#include #include #include #include diff --git a/include/boost/sort/common/util/search.hpp b/include/boost/sort/common/util/search.hpp index 1b86582..59647f3 100644 --- a/include/boost/sort/common/util/search.hpp +++ b/include/boost/sort/common/util/search.hpp @@ -9,7 +9,7 @@ #ifndef __BOOST_SORT_COMMON_SEARCH_HPP #define __BOOST_SORT_COMMON_SEARCH_HPP -#include + #include #include @@ -195,7 +195,7 @@ inline Iter_t lower_bound(Iter_t first, Iter_t last, assert((last - first) >= 0); if (last == first) return last; Iter_t itaux = internal_find_first(first, last, val, comp, flt); - return (itaux == (last - 1) and comp(flt(*itaux), val)) ? last : itaux; + return (itaux == (last - 1) && comp(flt(*itaux), val)) ? last : itaux; } //---------------------------------------------------------------------------- // function :upper_bound @@ -219,7 +219,7 @@ inline Iter_t upper_bound(Iter_t first, Iter_t last, assert((last - first) >= 0); if (last == first) return last; Iter_t itaux = internal_find_last(first, last, val, comp, flt); - return (itaux == first and comp(val, flt(*itaux))) ? itaux : itaux + 1; + return (itaux == first && comp(val, flt(*itaux))) ? itaux : itaux + 1; } ; //---------------------------------------------------------------------------- @@ -287,239 +287,7 @@ inline Iter_t insert_last(Iter_t first, Iter_t last, return upper_bound(first, last, val, comp, flt); } -/* - // - //########################################################################### - // ## - // ################################################################ ## - // # # ## - // # I N T E R N A L F U N C T I O N S # ## - // # # ## - // ################################################################ ## - // ## - // I M P O R T A N T ## - // ## - // These functions are not directly callable by the user, are for internal ## - // use only. ## - // These functions don't check the parameters ## - // ## - //########################################################################### - // - //----------------------------------------------------------------------------- - // function : internal_find_first - /// @brief find if a value exist in the range [first, last). - /// Always return as valid iterator in the range [first, last-1] - /// If exist return the iterator to the first occurrence. If don't exist - /// return the first greater than val. - /// If val is greater than the *(last-1), return (last-1) - /// If val is lower than (*first), return first - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter > - inline Iter_t internal_find_first ( Iter_t first, Iter_t last, - const value_iter &val, - const Compare & comp= Compare() ) - { - Iter_t LI = first , LS = last - 1, it_out = first; - while ( LI != LS) - { it_out = LI + ( (LS - LI) >> 1); - if ( comp ( *it_out, val)) LI = it_out + 1 ; else LS = it_out ; - } - return LS ; - } - // - //----------------------------------------------------------------------------- - // function : internal_find_last - /// @brief find if a value exist in the range [first, last). - /// Always return as valid iterator in the range [first, last-1] - /// If exist return the iterator to the last occurrence. - /// If don't exist return the first lower than val. - /// If val is greater than *(last-1) return (last-1). - /// If is lower than the first, return first - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, if not found return last - - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter > - inline Iter_t internal_find_last ( Iter_t first, Iter_t last , - const value_iter &val, - const Compare &comp= Compare() ) - { - Iter_t LI = first , LS = last - 1, it_out = first ; - while ( LI != LS) - { it_out = LI + ( (LS - LI + 1) >> 1); - if ( comp (val, *it_out)) LS = it_out - 1 ; else LI = it_out ; - } - return LS ; - } - - // - //########################################################################### - // ## - // ################################################################ ## - // # # ## - // # P U B L I C F U N C T I O N S # ## - // # # ## - // ################################################################ ## - // ## - //########################################################################### - // - //----------------------------------------------------------------------------- - // function : find_first - /// @brief find if a value exist in the range [first, last). If exist return the - /// iterator to the first occurrence. If don't exist return last - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, and if not last - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter > - inline Iter_t find_first ( Iter_t first, Iter_t last, - const value_iter &val, - Compare comp = Compare() ) - { - assert ( (last - first) >= 0 ); - if ( first == last) return last ; - Iter_t LS = internal_find_first ( first, last, val, comp); - return (comp (*LS, val) or comp (val, *LS))?last:LS; - } - // - //----------------------------------------------------------------------------- - // function : find_last - /// @brief find if a value exist in the range [first, last). If exist return the - /// iterator to the last occurrence. If don't exist return last - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, if not found return last - - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter > - inline Iter_t find_last ( Iter_t first, Iter_t last , - const value_iter &val, - Compare comp = Compare()) - { - assert ( (last - first ) >= 0 ); - if ( last == first ) return last ; - Iter_t LS = internal_find_last (first, last, val, comp); - return (comp (*LS, val) or comp (val, *LS))?last:LS ; - } - - //---------------------------------------------------------------------------- - // function : lower_bound - /// @brief Returns an iterator pointing to the first element in the range - /// [first, last) that is not less than (i.e. greater or equal to) val. - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter > - inline Iter_t lower_bound ( Iter_t first, Iter_t last , - const value_iter &val, - Compare &comp = Compare() ) - { - assert ( (last - first ) >= 0 ); - if ( last == first ) return last ; - Iter_t itaux = internal_find_first( first, last, val,comp); - return (itaux == (last - 1) and comp (*itaux, val))?last: itaux; - } - //---------------------------------------------------------------------------- - // function :upper_bound - /// @brief return the first element greather than val.If don't exist - /// return last - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found - /// @remarks - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter > - inline Iter_t upper_bound ( Iter_t first, Iter_t last , - const value_iter &val, - Compare &comp = Compare() ) - { - assert ( (last - first ) >= 0 ); - if ( last == first ) return last ; - Iter_t itaux = internal_find_last( first, last, val,comp); - return ( itaux == first and comp (val,*itaux))? itaux: itaux + 1; - } - //---------------------------------------------------------------------------- - // function :equal_range - /// @brief return a pair of lower_bound and upper_bound with the value val.If - /// don't exist return last in the two elements of the pair - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return pair of iterators - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter > - inline std::pair equal_range ( Iter_t first, Iter_t last , - const value_iter &val, - Compare &comp = Compare() ) - { - return std::make_pair(lower_bound(first, last, val,comp), - upper_bound(first, last, val,comp)); - } - // - //----------------------------------------------------------------------------- - // function : insert_first - /// @brief find if a value exist in the range [first, last). If exist return the - /// iterator to the first occurrence. If don't exist return last - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, and if not last - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter > - inline Iter_t insert_first ( Iter_t first, Iter_t last, - const value_iter &val, - Compare comp = Compare() ) - { - return lower_bound (first, last, val, comp); - } - // - //----------------------------------------------------------------------------- - // function : insert_last - /// @brief find if a value exist in the range [first, last). If exist return the - /// iterator to the last occurrence. If don't exist return last - // - /// @param [in] first : iterator to the first element of the range - /// @param [in] last : iterator to the last element of the range - /// @param [in] val : value to find - /// @param [in] comp : object for to compare two value_t objects - /// @return iterator to the element found, if not found return last - - //----------------------------------------------------------------------------- - template < class Iter_t, class Compare = compare_iter > - inline Iter_t insert_last ( Iter_t first, Iter_t last , - const value_iter &val, - Compare comp = Compare()) - { - return upper_bound (first, last, val, comp); - } - - */ // //**************************************************************************** } // End namespace util diff --git a/include/boost/sort/common/util/traits.hpp b/include/boost/sort/common/util/traits.hpp index f2819ea..5c65214 100644 --- a/include/boost/sort/common/util/traits.hpp +++ b/include/boost/sort/common/util/traits.hpp @@ -12,7 +12,6 @@ #ifndef __BOOST_SORT_COMMON_UTIL_TRAITS_HPP #define __BOOST_SORT_COMMON_UTIL_TRAITS_HPP -#include #include #include #include diff --git a/include/boost/sort/parallel_stable_sort/parallel_stable_sort.hpp b/include/boost/sort/parallel_stable_sort/parallel_stable_sort.hpp index 37f4613..a8d769d 100644 --- a/include/boost/sort/parallel_stable_sort/parallel_stable_sort.hpp +++ b/include/boost/sort/parallel_stable_sort/parallel_stable_sort.hpp @@ -13,7 +13,6 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_PARALLEL_STABLE_SORT_HPP #define __BOOST_SORT_PARALLEL_DETAIL_PARALLEL_STABLE_SORT_HPP -#include #include #include #include @@ -131,7 +130,7 @@ parallel_stable_sort nelem = range_initial.size(); size_t nptr = (nelem + 1) >> 1; - if (nelem < nelem_min or nthread < 2) + if (nelem < nelem_min || nthread < 2) { bss::spinsort (range_initial.first, range_initial.last, comp); @@ -141,13 +140,13 @@ parallel_stable_sort //------------------- check if sort -------------------------------------- bool sw = true; for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sw = not comp(*it2, *it1)); it1 = it2++); + it2 != last && (sw = ! comp(*it2, *it1)); it1 = it2++); if (sw) return; //------------------- check if reverse sort --------------------------- sw = true; for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sw = comp(*it2, *it1)); it1 = it2++); + it2 != last && (sw = comp(*it2, *it1)); it1 = it2++); if (sw) { using std::swap; diff --git a/include/boost/sort/sample_sort/sample_sort.hpp b/include/boost/sort/sample_sort/sample_sort.hpp index 095108a..6d6ecb5 100644 --- a/include/boost/sort/sample_sort/sample_sort.hpp +++ b/include/boost/sort/sample_sort/sample_sort.hpp @@ -13,7 +13,6 @@ #ifndef __BOOST_SORT_PARALLEL_DETAIL_SAMPLE_SORT_HPP #define __BOOST_SORT_PARALLEL_DETAIL_SAMPLE_SORT_HPP -#include #include #include #include @@ -249,13 +248,13 @@ sample_sort vfuture.resize(nthread); // Adjust when have many threads and only a few elements - while (nelem > thread_min and (nthread * nthread) > (nelem >> 3)) + while (nelem > thread_min && (nthread * nthread) > (nelem >> 3)) { nthread /= 2; }; ninterval = (nthread << 3); - if (nthread < 2 or nelem <= (thread_min)) + if (nthread < 2 || nelem <= (thread_min)) { bss::spinsort(first, last, comp); return; @@ -264,13 +263,13 @@ sample_sort //------------------- check if sort -------------------------------------- bool sw = true; for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sw = not comp(*it2, *it1)); it1 = it2++); + it2 != last && (sw = ! comp(*it2, *it1)); it1 = it2++); if (sw) return; //------------------- check if reverse sort --------------------------- sw = true; for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sw = comp(*it2, *it1)); it1 = it2++); + it2 != last && (sw = comp(*it2, *it1)); it1 = it2++); if (sw) { using std::swap; @@ -307,7 +306,7 @@ sample_sort { error = true; } - if (not error) + if (! error) { first_merge(); construct = true; @@ -334,7 +333,7 @@ void sample_sort::destroy_all(void) destroy(global_buf); construct = false; } - if (global_buf.first != nullptr and owner) + if (global_buf.first != nullptr && owner) std::free(global_buf.first); } // diff --git a/include/boost/sort/spinsort/spinsort.hpp b/include/boost/sort/spinsort/spinsort.hpp index 8895877..09b937a 100644 --- a/include/boost/sort/spinsort/spinsort.hpp +++ b/include/boost/sort/spinsort/spinsort.hpp @@ -13,8 +13,6 @@ #ifndef __BOOST_SORT_PARALLEL_ALGORITHM_SPIN_SORT_HPP #define __BOOST_SORT_PARALLEL_ALGORITHM_SPIN_SORT_HPP - -#include #include #include #include @@ -183,7 +181,7 @@ static bool check_stable_sort(const range &rng_data, bool sw = true; Iter1_t it2 = rng_data.first + 1; for (Iter1_t it1 = rng_data.first; - it2 != rng_data.last and (sw = not comp(*it2, *it1)); it1 = + it2 != rng_data.last && (sw = ! comp(*it2, *it1)); it1 = it2++) ; if (sw) return true; @@ -200,7 +198,7 @@ static bool check_stable_sort(const range &rng_data, if ((it2 != (rng_data.first + 1))) return false; sw = true; for (Iter1_t it1 = rng_data.first; - it2 != rng_data.last and (sw = comp(*it2, *it1)); it1 = + it2 != rng_data.last && (sw = comp(*it2, *it1)); it1 = it2++) ; if (size_t(rng_data.last - it2) >= min_insert_partial_sort) return false; @@ -257,7 +255,7 @@ static void range_sort(const range &range1, //----------------------------------------------------------------------- typedef range range_it1; typedef range range_it2; - assert(range1.size() == range2.size() and level != 0); + assert(range1.size() == range2.size() && level != 0); //------------------- check if sort -------------------------------------- if (range1.size() > 1024) @@ -420,7 +418,7 @@ public: destroy(range(ptr, ptr + nptr)); construct = false; }; - if (owner and ptr != nullptr) std::free (ptr); + if (owner && ptr != nullptr) std::free (ptr); }; }; @@ -464,13 +462,13 @@ spinsort //------------------- check if sort --------------------------------- bool sw = true; for (Iter_t it1 = first, it2 = first + 1; it2 != last - and (sw = not comp(*it2, *it1)); it1 = it2++) ; + && (sw = ! comp(*it2, *it1)); it1 = it2++) ; if (sw) return; //------------------- check if reverse sort ------------------------- sw = true; for (Iter_t it1 = first, it2 = first + 1; - it2 != last and (sw = comp(*it2, *it1)); it1 = it2++); + it2 != last && (sw = comp(*it2, *it1)); it1 = it2++); if (sw) { using std::swap; diff --git a/test/test_block_indirect_sort.cpp b/test/test_block_indirect_sort.cpp index 05f63cf..6badefd 100644 --- a/test/test_block_indirect_sort.cpp +++ b/test/test_block_indirect_sort.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -165,7 +164,7 @@ void test_int_array(uint32_t NELEM) bsp::block_indirect_sort(V1.begin(), V1.end()); for (unsigned i = 1; i < NELEM; i++) - { BOOST_CHECK(not (V1[i] < V1[i-1])); + { BOOST_CHECK (! (V1[i] < V1[i-1])); }; }; void test3 (void) diff --git a/test/test_flat_stable_sort.cpp b/test/test_flat_stable_sort.cpp index d1df52c..bf9b5e6 100644 --- a/test/test_flat_stable_sort.cpp +++ b/test/test_flat_stable_sort.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -61,7 +60,7 @@ void test1 ( ) BOOST_CHECK (V1.size ( ) == V2.size ( )); for (uint32_t i = 0; i < V1.size ( ); ++i) { - BOOST_CHECK (V1[ i ].num == V2[ i ].num and + BOOST_CHECK (V1[ i ].num == V2[ i ].num && V1[ i ].tail == V2[ i ].tail); }; }; @@ -130,7 +129,7 @@ void test3 (void) }; flat_stable_sort( V.begin() , V.end(), compare_t()); for ( uint32_t i =0 ; i < ( NELEM * 10); ++i) - { BOOST_CHECK ( V[i].num == (i / 10) and V[i].tail == (i %10) ); + { BOOST_CHECK ( V[i].num == (i / 10) && V[i].tail == (i %10) ); }; } int test_main (int, char *[]) diff --git a/test/test_insert_sort.cpp b/test/test_insert_sort.cpp index 4027edc..1537f96 100644 --- a/test/test_insert_sort.cpp +++ b/test/test_insert_sort.cpp @@ -10,7 +10,6 @@ /// /// @remarks //----------------------------------------------------------------------------- -#include #include #include #include @@ -99,7 +98,7 @@ void test02 (void) { BOOST_CHECK ((*(it - 1)) <= (*it)); }; - BOOST_CHECK (A[ 998 ] == 0 and A[ 999 ] == 0 and A[ 1000 + NELEM ] == 0 and + BOOST_CHECK (A[ 998 ] == 0 && A[ 999 ] == 0 && A[ 1000 + NELEM ] == 0 && A[ 1001 + NELEM ] == 0); @@ -115,8 +114,8 @@ void test02 (void) { BOOST_CHECK ((*(it - 1)) <= (*it)); }; - BOOST_CHECK (A[ 998 ] == 999999999 and A[ 999 ] == 999999999 and - A[ 1000 + NELEM ] == 999999999 and + BOOST_CHECK (A[ 998 ] == 999999999 && A[ 999 ] == 999999999 && + A[ 1000 + NELEM ] == 999999999 && A[ 1001 + NELEM ] == 999999999); }; diff --git a/test/test_parallel_stable_sort.cpp b/test/test_parallel_stable_sort.cpp index f790677..715905f 100644 --- a/test/test_parallel_stable_sort.cpp +++ b/test/test_parallel_stable_sort.cpp @@ -10,7 +10,7 @@ /// /// @remarks //----------------------------------------------------------------------------- -#include + #include #include #include @@ -61,12 +61,12 @@ void test1() BOOST_CHECK(V1.size() == V2.size()); for (uint32_t i = 0; i < V1.size(); ++i) - { BOOST_CHECK(V1[i].num == V2[i].num and V1[i].tail == V2[i].tail); + { BOOST_CHECK(V1[i].num == V2[i].num && V1[i].tail == V2[i].tail); }; BOOST_CHECK(V3.size() == V2.size()); for (uint32_t i = 0; i < V3.size(); ++i) - { BOOST_CHECK(V3[i].num == V2[i].num and V3[i].tail == V2[i].tail); + { BOOST_CHECK(V3[i].num == V2[i].num && V3[i].tail == V2[i].tail); }; }; @@ -170,7 +170,7 @@ void test5 (void) }; bss::parallel_stable_sort( V.begin() , V.end()); for ( uint32_t i =0 ; i < ( NELEM * 10); ++i) - { BOOST_CHECK ( V[i].num == (i / 10) and V[i].tail == (i %10) ); + { BOOST_CHECK ( V[i].num == (i / 10) && V[i].tail == (i %10) ); }; } diff --git a/test/test_sample_sort.cpp b/test/test_sample_sort.cpp index c23b56f..ca94ecf 100644 --- a/test/test_sample_sort.cpp +++ b/test/test_sample_sort.cpp @@ -10,7 +10,6 @@ /// /// @remarks //----------------------------------------------------------------------------- -#include #include #include #include @@ -59,12 +58,12 @@ void test1() BOOST_CHECK(V1.size() == V2.size()); for (uint32_t i = 0; i < V1.size(); ++i) - { BOOST_CHECK(V1[i].num == V2[i].num and V1[i].tail == V2[i].tail); + { BOOST_CHECK(V1[i].num == V2[i].num && V1[i].tail == V2[i].tail); }; BOOST_CHECK(V3.size() == V2.size()); for (uint32_t i = 0; i < V3.size(); ++i) - { BOOST_CHECK(V3[i].num == V2[i].num and V3[i].tail == V2[i].tail); + { BOOST_CHECK(V3[i].num == V2[i].num && V3[i].tail == V2[i].tail); }; }; @@ -168,7 +167,7 @@ void test5 (void) }; bss::sample_sort( V.begin() , V.end()); for ( uint32_t i =0 ; i < ( NELEM * 10); ++i) - { BOOST_CHECK ( V[i].num == (i / 10) and V[i].tail == (i %10) ); + { BOOST_CHECK ( V[i].num == (i / 10) && V[i].tail == (i %10) ); }; } diff --git a/test/test_spinsort.cpp b/test/test_spinsort.cpp index 91b5a43..8cf8a80 100644 --- a/test/test_spinsort.cpp +++ b/test/test_spinsort.cpp @@ -10,7 +10,6 @@ /// /// @remarks //----------------------------------------------------------------------------- -#include #include #include #include @@ -70,7 +69,7 @@ void test1 ( ) BOOST_CHECK (V1.size ( ) == V2.size ( )); for (uint32_t i = 0; i < V1.size ( ); ++i) { - BOOST_CHECK (V1[ i ].num == V2[ i ].num and + BOOST_CHECK (V1[ i ].num == V2[ i ].num && V1[ i ].tail == V2[ i ].tail); }; }; @@ -171,7 +170,7 @@ void test4 (void) }; spinsort( V.begin() , V.end(), compare_t()); for ( uint32_t i =0 ; i < ( NELEM * 10); ++i) - { BOOST_CHECK ( V[i].num == (i / 10) and V[i].tail == (i %10) ); + { BOOST_CHECK ( V[i].num == (i / 10) && V[i].tail == (i %10) ); }; } int test_main (int, char *[])