-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpair.hpp
More file actions
59 lines (53 loc) · 1.18 KB
/
Copy pathpair.hpp
File metadata and controls
59 lines (53 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// Created by Freewings on 2025/5/6.
//
#ifndef PAIR_HPP
#define PAIR_HPP
namespace sjtu{
template <typename T1,typename T2>
class pair{
public:
T1 first;
T2 second;
public:
pair(){}
pair(const pair<T1,T2> &p){
first=p.first;
second=p.second;
}
pair(const T1 &t1,const T2 &t2){
this->first=t1;
this->second=t2;
}
friend bool operator==(const pair<T1,T2> &p1,const pair<T1,T2> &p){
return p1.first==p.first && p1.second==p.second;
}
friend bool operator!=(const pair<T1,T2> &p1,const pair<T1,T2> &p){
return !(p1==p);
}
friend bool operator<(const pair<T1,T2> &p1,const pair<T1,T2> &p){
if(p1.first != p.first){
return p1.first < p.first;
}
else{
return p1.second < p.second;
}
}
friend bool operator>(const pair<T1,T2> &p1,const pair<T1,T2> &p){
if(p1.first != p.first){
return p.first < p1.first;
}
else{
return p.second < p1.second;
}
}
pair<T1,T2> operator=(const pair<T1,T2> &p){
if( *this != p){
first=p.first;
second=p.second;
}
return *this;
}
};
}
#endif //PAIR_HPP