dblume commited on 2025-01-21 13:07:32
Showing 9 changed files, with 29 additions and 14 deletions.
Also run clang-format on all the files.
... | ... |
@@ -16,7 +16,8 @@ int my_lib_helper_fn(int x) |
16 | 16 |
|
17 | 17 |
namespace MY_LIB { |
18 | 18 |
|
19 |
-my_lib_rect::my_lib_rect(int width, int height) : width_(width), height_(height) {} |
|
19 |
+my_lib_rect::my_lib_rect(int width, int height) : |
|
20 |
+ width_(width), height_(height) {} |
|
20 | 21 |
|
21 | 22 |
int my_lib_rect::area() const |
22 | 23 |
{ |
... | ... |
@@ -6,7 +6,8 @@ |
6 | 6 |
// Each byte will contain 7 bits of the number and the 8th bit will be |
7 | 7 |
// used to indicate if there are more bytes to follow |
8 | 8 |
|
9 |
-std::vector<unsigned char> serialize(unsigned long long value) { |
|
9 |
+std::vector<unsigned char> serialize(unsigned long long value) |
|
10 |
+{ |
|
10 | 11 |
std::vector<unsigned char> result; |
11 | 12 |
do { |
12 | 13 |
unsigned char byte = value & 0x7F; |
... | ... |
@@ -19,7 +20,8 @@ std::vector<unsigned char> serialize(unsigned long long value) { |
19 | 20 |
return result; |
20 | 21 |
} |
21 | 22 |
|
22 |
-unsigned long long deserialize(std::vector<unsigned char> const& bytes) { |
|
23 |
+unsigned long long deserialize(std::vector<unsigned char> const& bytes) |
|
24 |
+{ |
|
23 | 25 |
unsigned long long result = 0; |
24 | 26 |
for (auto it = bytes.rbegin(); it != bytes.rend(); ++it) { |
25 | 27 |
result <<= 7; |
... | ... |
@@ -78,9 +78,13 @@ void test_cpp14() |
78 | 78 |
|
79 | 79 |
struct Base |
80 | 80 |
{ |
81 |
- Base(): x_(0) {} |
|
81 |
+ Base() : |
|
82 |
+ x_(0) {} |
|
83 |
+ |
|
82 | 84 |
virtual ~Base() {} |
85 |
+ |
|
83 | 86 |
virtual void f() {} |
87 |
+ |
|
84 | 88 |
int x_; |
85 | 89 |
}; |
86 | 90 |
|
... | ... |
@@ -104,8 +109,8 @@ void writeNumber(int fd, T val, int base) |
104 | 109 |
printf("* buf starts at %p and ends at %p and is %ld long\n", buf, &buf[(sizeof(val) * 8) - 1], sizeof(val) * 8); |
105 | 110 |
|
106 | 111 |
int i = 30; |
107 |
- for(; val && i ; --i, val /= base) { |
|
108 | 112 |
// for(; val && i && (static_cast<int>(sizeof(val))*8 >= i); --i, val /= base) |
113 |
+ for (; val && i; --i, val /= base) { |
|
109 | 114 |
printf("** i=%d, writing %c to %p\n", i, "0123456789abcdef"[val % base], &buf[i - 1]); |
110 | 115 |
buf[i - 1] = "0123456789abcdef"[val % base]; |
111 | 116 |
} |
... | ... |
@@ -124,7 +129,8 @@ int main() |
124 | 129 |
cout << endl; |
125 | 130 |
writeNumber(1, v2, 8); |
126 | 131 |
writeNumber(1, v2, 2); |
127 |
- cout << endl << "DXB end!" << endl; |
|
132 |
+ cout << endl |
|
133 |
+ << "DXB end!" << endl; |
|
128 | 134 |
|
129 | 135 |
length_of_array = 6; |
130 | 136 |
int a[6] = {10, 20, 20, 30, 40, 40}; |
... | ... |
@@ -10,13 +10,16 @@ |
10 | 10 |
#include <ranges> |
11 | 11 |
#endif |
12 | 12 |
|
13 |
-class histogram { |
|
13 |
+class histogram |
|
14 |
+{ |
|
14 | 15 |
public: |
15 |
- void add(const std::string& word) { |
|
16 |
+ void add(const std::string& word) |
|
17 |
+ { |
|
16 | 18 |
++counter_map_[word]; |
17 | 19 |
} |
18 | 20 |
|
19 |
- void print_top(size_t n, std::ostream& os) const { |
|
21 |
+ void print_top(size_t n, std::ostream& os) const |
|
22 |
+ { |
|
20 | 23 |
using count = std::pair<std::string, size_t>; |
21 | 24 |
std::vector<count> popular(counter_map_.begin(), counter_map_.end()); |
22 | 25 |
#if __cplusplus == 202002L |
... | ... |
@@ -9,7 +9,8 @@ std::mutex g_mutex; |
9 | 9 |
std::set<scoped_set_adder*> g_items; |
10 | 10 |
} // namespace |
11 | 11 |
|
12 |
-scoped_set_adder::scoped_set_adder(std::string const& name) : name_(name) |
|
12 |
+scoped_set_adder::scoped_set_adder(std::string const& name) : |
|
13 |
+ name_(name) |
|
13 | 14 |
{ |
14 | 15 |
std::lock_guard<std::mutex> lock(g_mutex); |
15 | 16 |
g_items.insert(this); |