Apollo  v5.5.0
Open source self driving car software
i_struct.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
17 #pragma once
18 
20 
21 namespace apollo {
22 namespace perception {
23 namespace common {
24 template <typename T1, typename T2>
25 struct Pair {
26  T1 first;
27  T2 second;
28  Pair() {}
29  Pair(const Pair<T1, T2> &p) {
30  first = p.first;
31  second = p.second;
32  }
34  this->first = p.first;
35  this->second = p.second;
36  return (*this);
37  }
38  Pair(const T1 &a, const T2 &b) : first(a), second(b) {}
39 };
40 
41 template <typename T1, typename T2>
42 inline Pair<T1, T2> IMakePair(const T1 &a, const T2 &b) {
43  return Pair<T1, T2>(a, b);
44 }
45 
46 template <typename T1, typename T2>
47 inline bool ILessPairFirstElement(const Pair<T1, T2> &a,
48  const Pair<T1, T2> &b) {
49  return a.first < b.first;
50 }
51 
52 template <typename T1, typename T2>
53 inline bool ILessPairSecondElement(const Pair<T1, T2> &a,
54  const Pair<T1, T2> &b) {
55  return a.second < b.second;
56 }
57 
58 template <typename T1, typename T2>
60  const Pair<T1, T2> &b) {
61  return a.first > b.first;
62 }
63 
64 template <typename T1, typename T2>
66  const Pair<T1, T2> &b) {
67  return a.second > b.second;
68 }
69 
70 } // namespace common
71 } // namespace perception
72 } // namespace apollo
Pair(const Pair< T1, T2 > &p)
Definition: i_struct.h:29
Definition: blob.h:72
T2 second
Definition: i_struct.h:27
Pair()
Definition: i_struct.h:28
bool ILargerPairSecondElement(const Pair< T1, T2 > &a, const Pair< T1, T2 > &b)
Definition: i_struct.h:65
Pair(const T1 &a, const T2 &b)
Definition: i_struct.h:38
T1 first
Definition: i_struct.h:26
Pair< T1, T2 > IMakePair(const T1 &a, const T2 &b)
Definition: i_struct.h:42
bool ILargerPairFirstElement(const Pair< T1, T2 > &a, const Pair< T1, T2 > &b)
Definition: i_struct.h:59
bool ILessPairFirstElement(const Pair< T1, T2 > &a, const Pair< T1, T2 > &b)
Definition: i_struct.h:47
Definition: i_struct.h:25
bool ILessPairSecondElement(const Pair< T1, T2 > &a, const Pair< T1, T2 > &b)
Definition: i_struct.h:53
Pair & operator=(const Pair< T1, T2 > &p)
Definition: i_struct.h:33