Skip to content

Commit a290ae7

Browse files
chore: use iwyu on sorting/**.cpp
1 parent 19d136a commit a290ae7

29 files changed

+186
-142
lines changed

sorting/binary_insertion_sort.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@
3939
* \f{bmatrix}{10 &20 &30 &40 &50\f}
4040
*/
4141

42-
#include <algorithm> /// for algorithm functions
43-
#include <cassert> /// for assert
44-
#include <iostream> /// for IO operations
45-
#include <vector> /// for working with vectors
42+
#include <stdint.h> // for int64_t
43+
#include <algorithm> // for is_sorted
44+
#include <cassert> // for assert
45+
#include <iostream> // for basic_ostream, operator<<, char_traits, cout, endl
46+
#include <vector> // for vector
47+
#include <iterator> // for begin, end
4648

4749
/**
4850
* \namespace sorting

sorting/bitonic_sort.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
/* C++ Program for Bitonic Sort. Note that this program
44
works only when size of input is a power of 2. */
55

6-
#include <algorithm>
7-
#include <iostream>
6+
#include <iostream> // for char_traits, operator<<, basic_ostream, basic_os...
7+
#include <utility> // for swap
88

99
/*The parameter dir indicates the sorting direction, ASCENDING
1010
or DESCENDING; if (a[i] > a[j]) agrees with the direction,

sorting/bogo_sort.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
*
1515
* @author [Deep Raval](https://github.com/imdeep2905)
1616
*/
17-
#include <iostream>
18-
#include <algorithm>
19-
#include <array>
20-
#include <cassert>
21-
#include <random>
17+
#include <iostream> // for operator<<, basic_ostream, cout, char_traits
18+
#include <algorithm> // for is_sorted, shuffle
19+
#include <array> // for array
20+
#include <cassert> // for assert
21+
#include <random> // for random_device, mt19937
22+
#include <cstdlib> // for rand, size_t
2223

2324

2425
/**

sorting/bubble_sort.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ can't get the best status in the code we shared above. This happens on the
3737
optimized bubble sort algorithm. It's right down there.
3838
*/
3939

40-
#include <iostream>
41-
#include <vector>
40+
#include <iostream> // for char_traits, basic_ostream, operator<<, basic_os...
41+
#include <vector> // for vector
42+
#include <utility> // for swap
4243

4344
int main() {
4445
int n;

sorting/cocktail_selection_sort.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// array simultaneously, and swaps it with the lowest and highest available
44
// position iteratively or recursively
55

6-
#include <algorithm>
7-
#include <iostream>
8-
#include <vector>
6+
#include <iostream> // for operator<<, basic_ostream, char_traits, basic_is...
7+
#include <vector> // for vector
8+
#include <utility> // for swap
99

1010
// Iterative Version
1111

sorting/comb_sort.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
*
1616
*/
1717

18-
#include <algorithm>
19-
#include <cassert>
20-
#include <iostream>
18+
#include <algorithm> // for is_sorted, max
19+
#include <cassert> // for assert
20+
#include <iostream> // for char_traits, operator<<, basic_istream::operator>>
21+
#include <utility> // for swap
2122

2223
/**
2324
*

sorting/counting_sort_string.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// C++ Program for counting sort
2-
#include <iostream>
2+
#include <iostream> // for char_traits, basic_ostream, operator<<, basic_is...
3+
#include <string> // for basic_string, string, operator<<, operator>>
34

45
using namespace std;
56

sorting/cycle_sort.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
* @author [TsungHan Ho](https://github.com/dalaoqi)
1212
*/
1313

14-
#include <algorithm> /// for std::is_sorted, std::swap
15-
#include <cassert> /// for assert
16-
#include <cstdint> /// for integral typedefs
17-
#include <iostream> /// for io operations
18-
#include <vector> /// for std::vector
14+
#include <algorithm> // for is_sorted
15+
#include <cassert> // for assert
16+
#include <cstddef> // for size_t
17+
#include <cstdint> // for uint32_t
18+
#include <iostream> // for basic_ostream, operator<<, char_traits, cout, endl
19+
#include <iterator> // for begin, end
20+
#include <utility> // for swap
21+
#include <vector> // for vector
1922

2023
/**
2124
* @namespace sorting

sorting/dnf_sort.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
* @author [Sujal Gupta](https://github.com/heysujal)
1111
*/
1212

13-
#include <algorithm> /// for std::is_sorted
14-
#include <cassert> /// for assert
15-
#include <cstdint> /// for integral typedefs
16-
#include <iostream> /// for std::swap and io operations
17-
#include <vector> /// for std::vector
13+
#include <algorithm> // for is_sorted
14+
#include <cassert> // for assert
15+
#include <cstdint> // for uint64_t
16+
#include <iostream> // for basic_ostream, operator<<, char_traits, cout, endl
17+
#include <vector> // for vector
18+
#include <iterator> // for begin, end
19+
#include <utility> // for swap
1820

1921
/**
2022
* @namespace sorting

sorting/gnome_sort.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
* can be \f$O(n)\f$.
1616
*/
1717

18-
#include <algorithm> // for std::swap
19-
#include <array> // for std::array
20-
#include <cassert> // for assertions
21-
#include <iostream> // for io operations
18+
#include <algorithm> // for is_sorted
19+
#include <array> // for array
20+
#include <cassert> // for assert
21+
#include <iostream> // for operator<<, basic_ostream, cout, char_traits, endl
22+
#include <cstdlib> // for rand, size_t
23+
#include <iterator> // for begin, end
24+
#include <utility> // for swap
2225

2326
/**
2427
* @namespace sorting

0 commit comments

Comments
 (0)