sources/geometry.h

changeset 69
eb4c25284a19
parent 1
4dd5bde4e777
child 73
07dda51a7a8e
equal deleted inserted replaced
68:202e74157de5 69:eb4c25284a19
41 41
42 Position() : 42 Position() :
43 x (0), 43 x (0),
44 y (0) {} 44 y (0) {}
45 45
46 inline METHOD operator< (const Position& other) const -> bool; 46 bool operator< (const Position& other) const
47 inline METHOD operator> (const Position& other) const -> bool; 47 {
48 inline METHOD operator== (const Position& other) const -> bool; 48 if (y != other.y)
49 inline METHOD operator<= (const Position& other) const -> bool; 49 return y < other.y;
50 inline METHOD operator>= (const Position& other) const -> bool; 50
51 inline METHOD operator!= (const Position& other) const -> bool; 51 return x < other.x;
52 }
53
54 bool operator> (const Position& other) const
55 {
56 if (y != other.y)
57 return y > other.y;
58
59 return x > other.x;
60 }
61
62 bool operator== (const Position& other) const
63 {
64 return y == other.y and x == other.x;
65 }
66
67 bool operator!= (const Position& other) const
68 {
69 return not operator== (other);
70 }
71
72 bool operator<= (const Position& other) const
73 {
74 return not operator> (other);
75 }
76
77 bool operator>= (const Position& other) const
78 {
79 return not operator< (other);
80 }
52 }; 81 };
53 82
54 // ------------------------------------------------------------------------------------------------- 83 // -------------------------------------------------------------------------------------------------
55 84
56 struct Size 85 struct Size
82 111
83 Rectangle() : 112 Rectangle() :
84 Position(), 113 Position(),
85 Size() {} 114 Size() {}
86 }; 115 };
87
88 // -------------------------------------------------------------------------------------------------
89
90 inline METHOD
91 Position::operator< (const Position& other) const -> bool
92 {
93 if (y != other.y)
94 return y < other.y;
95
96 return x < other.x;
97 }
98
99 // -------------------------------------------------------------------------------------------------
100
101 inline METHOD
102 Position::operator> (const Position& other) const -> bool
103 {
104 if (y != other.y)
105 return y > other.y;
106
107 return x > other.x;
108 }
109
110 // -------------------------------------------------------------------------------------------------
111
112 inline METHOD
113 Position::operator== (const Position& other) const -> bool
114 {
115 return y == other.y and x == other.x;
116 }
117
118 // -------------------------------------------------------------------------------------------------
119
120 inline METHOD
121 Position::operator<= (const Position& other) const -> bool
122 {
123 return not operator> (other);
124 }
125
126 // -------------------------------------------------------------------------------------------------
127
128 inline METHOD
129 Position::operator>= (const Position& other) const -> bool
130 {
131 return not operator< (other);
132 }
133
134 // -------------------------------------------------------------------------------------------------
135
136 inline METHOD
137 Position::operator!= (const Position& other) const -> bool
138 {
139 return not operator== (other);
140 }

mercurial