File tree Expand file tree Collapse file tree 4 files changed +666
-0
lines changed
Expand file tree Collapse file tree 4 files changed +666
-0
lines changed Original file line number Diff line number Diff line change 1+ test
2+ * ~
3+ * .swp
4+
Original file line number Diff line number Diff line change 1+
2+ test : timsort.hpp test.cpp
3+ $(CXX ) -Wall -Wextra -std=c++0x test.cpp -o $@
Original file line number Diff line number Diff line change 1+ #include < iostream>
2+ #include < vector>
3+
4+ #include " timsort.hpp"
5+
6+
7+ template <typename T>
8+ int compare (T x, T y) {
9+ if (x == y) {
10+ return 0 ;
11+ }
12+ else if (x < 0 ) {
13+ return -1 ;
14+ }
15+ else {
16+ return 1 ;
17+ }
18+ }
19+
20+ int main () {
21+ std::vector<int > a;
22+ a.push_back (6 );
23+ a.push_back (5 );
24+ a.push_back (10 );
25+ a.push_back (4 );
26+ a.push_back (8 );
27+ a.push_back (2 );
28+ a.push_back (3 );
29+ a.push_back (7 );
30+ a.push_back (1 );
31+ a.push_back (9 );
32+
33+ timsort (a.begin (), a.end (), &compare<int >);
34+
35+ for (std::vector<int >::const_iterator i = a.begin ();
36+ i != a.end ();
37+ ++i ) {
38+ std::cout << *i << std::endl;
39+ }
40+ return 0 ;
41+ }
42+
You can’t perform that action at this time.
0 commit comments