图  0.1
数据结构_第13章
Set.h
Go to the documentation of this file.
1 
14 #ifndef INCLUDE_SET_H_
15 #define INCLUDE_SET_H_
16 
17 #include <utility>
18 
23 namespace Set
24 {
25  template <class Key_T, class Other_T = Key_T>
26  struct Set
27  {
28  // Member variables
29  Key_T key_;
30  Other_T other_;
31 
32  // Member functions
39  explicit Set(const Key_T &key, const Other_T &other = Other_T{}) : key_{key}, other_{other} {}
40 
41  // Non-member function overloads
50  friend bool operator<(const Set &lhs, const Set &rhs) { return lhs.key_ < rhs.key_; }
51 
60  friend bool operator>(const Set &lhs, const Set &rhs) { return lhs.key_ > rhs.key_; }
61 
70  friend bool operator<=(const Set &lhs, const Set &rhs) { return lhs.key_ <= rhs.key_; }
71 
80  friend bool operator>=(const Set &lhs, const Set &rhs) { return lhs.key_ >= rhs.key_; }
81 
90  friend bool operator==(const Set &lhs, const Set &rhs) { return lhs.key_ == rhs.key_; }
91 
100  friend bool operator!=(const Set &lhs, const Set &rhs) { return lhs.key_ != rhs.key_; }
101  };
102 } // namespace Set
103 
104 #endif /* INCLUDE_SET_H_ */
Set::Set::operator>
friend bool operator>(const Set &lhs, const Set &rhs)
operator>
Definition: Set.h:60
Set::Set::operator==
friend bool operator==(const Set &lhs, const Set &rhs)
operator==
Definition: Set.h:90
Set::Set::other_
Other_T other_
c 键值
Definition: Set.h:30
Set::Set::operator>=
friend bool operator>=(const Set &lhs, const Set &rhs)
operator>=
Definition: Set.h:80
Set::Set::operator<=
friend bool operator<=(const Set &lhs, const Set &rhs)
operator<=
Definition: Set.h:70
Set::Set::key_
Key_T key_
Definition: Set.h:29
Set::Set::operator<
friend bool operator<(const Set &lhs, const Set &rhs)
operator<
Definition: Set.h:50
Set
集合
Definition: Set.h:23
Set::Set::operator!=
friend bool operator!=(const Set &lhs, const Set &rhs)
operator!=
Definition: Set.h:100
Set::Set::Set
Set(const Key_T &key, const Other_T &other=Other_T{})
c 其他值
Definition: Set.h:39