Skip to content

Commit 1d88817

Browse files
committed
Merge pull request #12 from gfx/clang-format
Introduce clang-format
2 parents 1a39b9e + 8084b2b commit 1d88817

File tree

4 files changed

+402
-436
lines changed

4 files changed

+402
-436
lines changed

.clang-format

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
2+
BasedOnStyle: LLVM
3+
ColumnLimit: 120
4+
IndentWidth: 4
5+
AllowShortFunctionsOnASingleLine: false
6+
Standard: Cpp03

example/bench.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,17 @@
1313

1414
using namespace gfx;
1515

16-
enum state_t {
17-
sorted, randomized, reversed
18-
};
16+
enum state_t { sorted, randomized, reversed };
1917

20-
template <typename value_t>
21-
static void bench(int const size, state_t const state) {
18+
template <typename value_t> static void bench(int const size, state_t const state) {
2219
std::cerr << "size\t" << size << std::endl;
2320

2421
std::vector<value_t> a;
25-
for(int i = 0; i < size; ++i) {
26-
a.push_back(boost::lexical_cast<value_t>((i+1) * 10));
22+
for (int i = 0; i < size; ++i) {
23+
a.push_back(boost::lexical_cast<value_t>((i + 1) * 10));
2724
}
2825

29-
switch(state) {
26+
switch (state) {
3027
case randomized:
3128
std::random_shuffle(a.begin(), a.end());
3229
break;
@@ -45,7 +42,7 @@ static void bench(int const size, state_t const state) {
4542
std::vector<value_t> b(a);
4643
boost::timer t;
4744

48-
for(int i = 0; i < 100; ++i) {
45+
for (int i = 0; i < 100; ++i) {
4946
std::copy(a.begin(), a.end(), b.begin());
5047
std::sort(b.begin(), b.end());
5148
}
@@ -57,7 +54,7 @@ static void bench(int const size, state_t const state) {
5754
std::vector<value_t> b(a);
5855
boost::timer t;
5956

60-
for(int i = 0; i < 100; ++i) {
57+
for (int i = 0; i < 100; ++i) {
6158
std::copy(a.begin(), a.end(), b.begin());
6259
std::stable_sort(b.begin(), b.end());
6360
}
@@ -69,7 +66,7 @@ static void bench(int const size, state_t const state) {
6966
std::vector<value_t> b(a);
7067
boost::timer t;
7168

72-
for(int i = 0; i < 100; ++i) {
69+
for (int i = 0; i < 100; ++i) {
7370
std::copy(a.begin(), a.end(), b.begin());
7471
timsort(b.begin(), b.end());
7572
}
@@ -87,9 +84,7 @@ static void doit(int const n, state_t const state) {
8784
}
8885

8986
int main(int argc, const char *argv[]) {
90-
const int N = argc > 1
91-
? boost::lexical_cast<int>(argv[1])
92-
: 100 * 1000;
87+
const int N = argc > 1 ? boost::lexical_cast<int>(argv[1]) : 100 * 1000;
9388

9489
std::cerr << std::setprecision(6) << std::setiosflags(std::ios::fixed);
9590

0 commit comments

Comments
 (0)