1 | #include <algorithm>
|
---|
2 | #include <string>
|
---|
3 | #include <vector>
|
---|
4 |
|
---|
5 | struct Value {
|
---|
6 | int node;
|
---|
7 | };
|
---|
8 |
|
---|
9 | template<typename T>
|
---|
10 | struct NodeComparator {
|
---|
11 | bool operator()(const T& a, const T& b) {
|
---|
12 | return a < b;
|
---|
13 | }
|
---|
14 | };
|
---|
15 |
|
---|
16 | struct List : public std::vector<Value> {
|
---|
17 | using ValueType = Value;
|
---|
18 | };
|
---|
19 |
|
---|
20 | struct DumpContext {};
|
---|
21 |
|
---|
22 | namespace JSC {
|
---|
23 | namespace DFG {
|
---|
24 | template<typename T>
|
---|
25 | std::string nodeValuePairListDump(const T& nodeValuePairList, DumpContext* context = 0)
|
---|
26 | {
|
---|
27 | using V = typename T::ValueType;
|
---|
28 | T sortedList = nodeValuePairList;
|
---|
29 | std::sort(sortedList.begin(), sortedList.end(), [](const V& a, const V& b) {
|
---|
30 | return NodeComparator<int>()(a.node, b.node);
|
---|
31 | });
|
---|
32 | return "";
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | int main(int argc, char** argv)
|
---|
38 | {
|
---|
39 | List l;
|
---|
40 | l.push_back(Value{.node = 2});
|
---|
41 | l.push_back(Value{.node = 1});
|
---|
42 | JSC::DFG::nodeValuePairListDump<List>(l);
|
---|
43 | return 0;
|
---|
44 | }
|
---|