1 #include <iostream>
2 #include <vector>
3 #include <algorithm>
4 using namespace std;
5
6 class CellTrpPairInfo {
7 public:
8 CellTrpPairInfo() {
9 trpPairList_.clear();
10 }
11
12 ~CellTrpPairInfo() {
13 trpPairList_.erase(trpPairList_.begin(), trpPairList_.end());
14 }
15
16 void AddTrpPairInfo(const std::pair<int, int> &trpPair) {
17 trpPairList_.push_back(trpPair);
18 }
19
20 void printfTrpPairInfo() {
21 for (const auto &pair : trpPairList_) {
22 std::cout << pair.first << "->" << pair.second << endl;
23 }
24 }
25
26 std::vector<std::pair<int, int>> getTrpPairList() {
27 return trpPairList_;
28 }
29
30 void checkTrpPairInfo(const std::vector<std::pair<int, int>> &expectTrpPair) {
31 std::vector<std::pair<int, int>> actualTrpPair = getTrpPairList();
32 std::sort(actualTrpPair.begin(), actualTrpPair.end(), [](std::pair<int, int> p1, std::pair<int, int> p2)
33 { return p1.first < p2.first; });
34 std::cout << "checkTrpPairInfo:" << endl;
35 for (unsigned int i = 0; i < expectTrpPair.size(); i++) {
36 if (expectTrpPair[i].first == actualTrpPair[i].first &&
37 expectTrpPair[i].second == actualTrpPair[i].second) {
38 std::cout << expectTrpPair[i].first << "->" << expectTrpPair[i].second << endl;
39 } else {
40 std::cout << "check failed!" << endl;
41 return;
42 }
43 }
44 return;
45 }
46
47 private:
48 std::vector<std::pair<int, int>> trpPairList_;
49 };
50
51 int main()
52 {
53 CellTrpPairInfo *cellInfo = new CellTrpPairInfo(50);
54 std::vector<std::pair<int, int>> vec = {{1, 4}, {0, 3}, {2, 5}};
55 for (const auto &pair : vec) {
56 cellInfo->AddTrpPairInfo(pair);
57 }
58 cellInfo->printfTrpPairInfo();
59 std::vector<std::pair<int, int>> vec1 = {{0, 3}, {1, 4}, {2, 5}};
60 cellInfo->checkTrpPairInfo(vec1);
61 delete cellInfo;
62 system("pause");
63 return 0;
64 }