Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a3b719e

Browse files
chore: use iwyu on data_structures/**.cpp
1 parent 24e597f commit a3b719e

30 files changed

+602
-634
lines changed

data_structures/binary_search_tree.cpp

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* \warning This program is a poor implementation - C style - and does not
77
* utilize any of the C++ STL features.
88
*/
9-
#include <iostream>
9+
#include <cstddef> // for NULL
10+
#include <iostream> // for operator<<, basic_ostream, char_traits, cout
1011

1112
struct node {
1213
int val;
@@ -145,28 +146,28 @@ int main() {
145146
std::cin >> ch;
146147
int x;
147148
switch (ch) {
148-
case 1:
149-
std::cout << "\nEnter the value to be Inserted : ";
150-
std::cin >> x;
151-
Insert(root, x);
152-
break;
153-
case 2:
154-
std::cout << "\nEnter the value to be Deleted : ";
155-
std::cin >> x;
156-
Remove(root, root, x);
157-
break;
158-
case 3:
159-
BFT(root);
160-
break;
161-
case 4:
162-
Pre(root);
163-
break;
164-
case 5:
165-
In(root);
166-
break;
167-
case 6:
168-
Post(root);
169-
break;
149+
case 1:
150+
std::cout << "\nEnter the value to be Inserted : ";
151+
std::cin >> x;
152+
Insert(root, x);
153+
break;
154+
case 2:
155+
std::cout << "\nEnter the value to be Deleted : ";
156+
std::cin >> x;
157+
Remove(root, root, x);
158+
break;
159+
case 3:
160+
BFT(root);
161+
break;
162+
case 4:
163+
Pre(root);
164+
break;
165+
case 5:
166+
In(root);
167+
break;
168+
case 6:
169+
Post(root);
170+
break;
170171
}
171172
} while (ch != 0);
172173

data_structures/binary_search_tree2.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
* @see binary_search_tree.cpp
66
*/
77

8-
#include <cassert>
9-
#include <functional>
10-
#include <iostream>
11-
#include <memory>
12-
#include <vector>
8+
#include <cassert> // for assert
9+
#include <functional> // for function
10+
#include <iostream> // for basic_ostream, operator<<, cout, char_traits
11+
#include <memory> // for operator==, unique_ptr, allocator
12+
#include <vector> // for vector, operator==
13+
#include <cstddef> // for size_t
14+
#include <utility> // for move
1315

1416
/**
1517
* @brief The Binary Search Tree class.

data_structures/bloom_filter.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
* @author [DanArmor](https://github.com/DanArmor)
2323
*/
2424

25-
#include <cassert> /// for assert
26-
#include <functional> /// for list of hash functions for bloom filter constructor
27-
#include <initializer_list> /// for initializer_list for bloom filter constructor
28-
#include <string> /// for testing on strings
29-
#include <vector> /// for std::vector
30-
#include <iostream> /// for IO operations
25+
#include <cassert> // for assert
26+
#include <functional> // for function
27+
#include <initializer_list> // for initializer_list
28+
#include <string> // for basic_string, string
29+
#include <vector> // for vector
30+
#include <iostream> // for operator<<, basic_ostream, cout
31+
#include <cstddef> // for size_t
3132

3233
/**
3334
* @namespace data_structures

data_structures/cll/cll.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
A simple class for Cicular Linear Linked List
33
*/
44
#include "cll.h"
5+
6+
#include <cstdlib> // for NULL
7+
#include <iostream> // for basic_ostream, char_traits, operator<<, cout
8+
59
using namespace std;
610

711
/* Constructor */

data_structures/cll/main_cll.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#include "cll.h"
1+
#include <iostream> // for basic_ostream, operator<<, char_traits, cout, endl
2+
3+
#include "cll.h" // for cll
4+
25
using namespace std;
36

47
int main() {

data_structures/doubly_linked_list.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#include <cstdio>
2-
#include <cstdlib>
3-
#include <iostream>
1+
#include <cstdio> // for NULL
2+
#include <iostream> // for operator<<, basic_ostream, cout, char_traits
43

54
struct node {
65
int val;

data_structures/dsu_path_compression.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
* @see dsu_union_rank.cpp
1919
*/
2020

21-
#include <cassert> /// for assert
22-
#include <cstdint> /// for integral typedefs
23-
#include <iostream> /// for IO operations
24-
#include <vector> /// for std::vector
21+
#include <cassert> // for assert
22+
#include <cstdint> // for uint64_t
23+
#include <iostream> // for char_traits, basic_ostream, operator<<, cout, endl
24+
#include <vector> // for vector
25+
#include <algorithm> // for max, min
26+
#include <utility> // for swap
2527

2628
using std::cout;
2729
using std::endl;

data_structures/dsu_union_rank.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
* @see dsu_path_compression.cpp
2020
*/
2121

22-
#include <cassert> /// for assert
23-
#include <cstdint> /// for integral typedefs
24-
#include <iostream> /// for IO operations
25-
#include <vector> /// for std::vector
22+
#include <cassert> // for assert
23+
#include <cstdint> // for uint64_t
24+
#include <iostream> // for char_traits, basic_ostream, operator<<, cout, endl
25+
#include <vector> // for vector
26+
#include <utility> // for swap
2627

2728
using std::cout;
2829
using std::endl;

data_structures/linked_list.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
* to point to the node that the current node is pointing to, and then returning
1515
* the current node to heap store.
1616
*/
17-
#include <iostream>
18-
#include <memory>
19-
#include <string>
17+
#include <ctype.h> // for isdigit
18+
#include <iostream> // for operator<<, basic_ostream, cout, basic_istream, cin
19+
#include <memory> // for shared_ptr, __shared_ptr_access, make_shared
20+
#include <string> // for char_traits, basic_string, operator>>, stoi, string
2021

2122
/**
2223
* @namespace data_structures

data_structures/list_array.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
* and print the list.
1515
*/
1616

17-
#include <array> /// for std::array
18-
#include <cassert> /// for assert
19-
#include <cstdint> /// for integral typedefs
20-
#include <iostream> /// for io operations
17+
#include <array> // for array
18+
#include <cassert> // for assert
19+
#include <cstdint> // for uint64_t
20+
#include <iostream> // for operator<<, basic_ostream::operator<<, basic_ost...
21+
#include <utility> // for swap
2122

2223
/**
2324
* @namespace data_structures

data_structures/morrisinorder.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#include <iostream>
2-
#include <queue>
1+
#include <cstddef> // for NULL
2+
#include <iostream> // for char_traits, operator<<, basic_ostream, basic_os...
3+
#include <queue> // for queue
34

45
/**************************
56
@author shrutisheoran

data_structures/queue_using_array.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
* @author [Pooja](https://github.com/pooja-git11)
1818
* @author [Farbod Ahmadian](https://github.com/farbodahm)
1919
*/
20-
#include <array> /// for std::array
21-
#include <cstdint> /// for integral typedefs
22-
#include <iostream> /// for io operations
20+
#include <stdlib.h> // for exit
21+
#include <array> // for array
22+
#include <cstdint> // for int16_t, int8_t, uint16_t
23+
#include <iostream> // for operator<<, basic_ostream, cout, char_traits
2324

2425
constexpr uint16_t max_size{10}; ///< Maximum size of the queue
2526

data_structures/queue_using_linked_list.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#include <iostream>
1+
#include <cstddef> // for NULL
2+
#include <iostream> // for operator<<, basic_ostream, char_traits, cout
3+
24
using namespace std;
35

46
struct node {

data_structures/queue_using_linkedlist.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/*
22
Write a program to implement Queue using linkedlist.
33
*/
4-
#include <iostream>
4+
#include <stdlib.h> // for NULL, exit
5+
#include <iostream> // for operator<<, basic_ostream, cout, char_traits
56

67
struct linkedlist {
78
int data;

data_structures/queue_using_two_stacks.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
* Implementation of a Queue using two Stacks.
66
*/
77

8-
#include <cassert>
9-
#include <iostream>
10-
#include <stack>
8+
#include <stdlib.h> // for exit
9+
#include <cassert> // for assert
10+
#include <iostream> // for operator<<, basic_ostream, char_traits, cout, cerr
11+
#include <stack> // for stack
1112

1213
namespace {
1314
/**

0 commit comments

Comments
 (0)