BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
quadruple.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 // $Id: quadruple.h,v 1.13 2003/08/26 08:04:11 oliver Exp $
5 //
6 
7 #ifndef BALL_DATATYPE_QUADRUPLE_H
8 #define BALL_DATATYPE_QUADRUPLE_H
9 
10 #ifndef BALL_COMMON_H
11 # include <BALL/common.h>
12 #endif
13 
14 namespace BALL
15 {
21  template <typename T1, typename T2, typename T3, typename T4>
22  class Quadruple
23  {
24  public:
25 
29 
31 
32 
35  Quadruple();
36 
42  Quadruple(const Quadruple& quadruple, bool deep = true);
43 
52  Quadruple(const T1& new_first, const T2& new_second,
53  const T3& new_third, const T4& new_fourth);
54 
58  virtual ~Quadruple();
60 
63  virtual void clear();
64 
68 
73  const Quadruple& operator = (const Quadruple& quadruple);
74 
77  void set(const T1& t1, const T2& t2, const T3& t3, const T4& t4);
78 
81  void get(T1& first, T2& second, T3& third, T4& fourth) const;
82 
84 
87 
91  bool operator == (const Quadruple& quadruple) const;
92 
95  bool operator != (const Quadruple& quadruple) const;
96 
102  bool operator < (const Quadruple& quadruple) const;
103 
106  bool operator <= (const Quadruple& quadruple) const;
107 
110  bool operator >= (const Quadruple& quadruple) const;
111 
114  bool operator > (const Quadruple& quadruple) const;
115 
117 
121 
124  T1 first;
125 
128  T2 second;
129 
132  T3 third;
133 
136  T4 fourth;
138  };
139 
140  template <typename T1, typename T2, typename T3, typename T4>
142  {
143  }
144 
145  template <typename T1, typename T2, typename T3, typename T4>
147  (const Quadruple<T1, T2, T3, T4>& quadruple, bool /* deep */)
148  : first(quadruple.first),
149  second(quadruple.second),
150  third(quadruple.third),
151  fourth(quadruple.fourth)
152  {
153  }
154 
155  template <typename T1, typename T2, typename T3, typename T4>
157  (const T1& new_first, const T2& new_second, const T3& new_third, const T4& fourth)
158  : first(new_first),
159  second(new_second),
160  third(new_third),
161  fourth(fourth)
162  {
163  }
164 
165  template <typename T1, typename T2, typename T3, typename T4>
167  {
168  }
169 
170  template <typename T1, typename T2, typename T3, typename T4>
171  BALL_INLINE
172  void Quadruple<T1, T2, T3, T4>::set(const T1& new_first, const T2& new_second, const T3& new_third, const T4& new_fourth)
173 
174  {
175  first = new_first;
176  second = new_second;
177  third = new_third;
178  fourth = new_fourth;
179  }
180 
181  template <typename T1, typename T2, typename T3, typename T4>
182  BALL_INLINE
184  (const Quadruple<T1, T2, T3, T4>& quadruple)
185  {
186  first = quadruple.first;
187  second = quadruple.second;
188  third = quadruple.third;
189  fourth = quadruple.fourth;
190 
191  return *this;
192  }
193 
194  template <typename T1, typename T2, typename T3, typename T4>
195  BALL_INLINE
196  void Quadruple<T1, T2, T3, T4>::get(T1& t1, T2& t2, T3& t3, T4& t4) const
197  {
198  t1 = first;
199  t2 = second;
200  t3 = third;
201  t4 = fourth;
202  }
203 
204  template <typename T1, typename T2, typename T3, typename T4>
205  BALL_INLINE
207  {
208  return (first == quadruple.first
209  && second == quadruple.second
210  && third == quadruple.third
211  && fourth == quadruple.fourth);
212  }
213 
214  template <typename T1, typename T2, typename T3, typename T4>
215  BALL_INLINE
217  {
218  return (first != quadruple.first
219  || second != quadruple.second
220  || third != quadruple.third
221  || fourth != quadruple.fourth);
222  }
223 
224  template <typename T1, typename T2, typename T3, typename T4>
225  BALL_INLINE
227  {
228  first = T1();
229  second = T2();
230  third = T3();
231  fourth = T4();
232  }
233 
234  template <typename T1, typename T2, typename T3, typename T4>
235  BALL_INLINE
237  (const Quadruple<T1, T2, T3, T4>& quadruple) const
238  {
239  return (first < quadruple.first ||
240  (first == quadruple.first && second < quadruple.second) ||
241  (first == quadruple.first && second == quadruple.second && third < quadruple.third) ||
242  (first == quadruple.first && second == quadruple.second && third == quadruple.third
243  && fourth < quadruple.fourth));
244  }
245 
246  template <typename T1, typename T2, typename T3, typename T4>
247  BALL_INLINE
249  (const Quadruple<T1, T2, T3, T4>& quadruple) const
250  {
251  return (first < quadruple.first ||
252  (first == quadruple.first && second < quadruple.second) ||
253  (first == quadruple.first && second == quadruple.second && third < quadruple.third) ||
254  (first == quadruple.first && second == quadruple.second && third == quadruple.third
255  && fourth <= quadruple.fourth));
256  }
257 
258  template <typename T1, typename T2, typename T3, typename T4>
259  BALL_INLINE
261  (const Quadruple<T1, T2, T3, T4>& quadruple) const
262  {
263  return (first > quadruple.first ||
264  (first == quadruple.first && second > quadruple.second) ||
265  (first == quadruple.first && second == quadruple.second && third > quadruple.third) ||
266  (first == quadruple.first && second == quadruple.second && third == quadruple.third
267  && fourth >= quadruple.fourth));
268  }
269 
270  template <typename T1, typename T2, typename T3, typename T4>
271  BALL_INLINE
273  (const Quadruple<T1, T2, T3, T4>& quadruple) const
274  {
275  return (first > quadruple.first ||
276  (first == quadruple.first && second > quadruple.second) ||
277  (first == quadruple.first && second == quadruple.second && third > quadruple.third) ||
278  (first == quadruple.first && second == quadruple.second && third == quadruple.third
279  && fourth > quadruple.fourth));
280  }
281 } // namespace BALL
282 
283 #endif // BALL_DATATYPE_QUADRUPLE_H