00001
00023 #ifndef TUPLE_H_
00024 #define TUPLE_H_
00025
00026 class Tuple {
00027 double _t[2];
00028 long _id;
00029 public:
00030 Tuple(double x, double y, long id) { _t[0] = x; _t[1] = y; _id = id; }
00031 Tuple() { }
00032 ~Tuple() { }
00033
00034 inline double x() const { return _t[0]; }
00035 inline double y() const { return _t[1]; }
00036 inline long id() const { return _id; }
00037 bool operator==(const Tuple& rhs) const {
00038 for (int i = 0; i < 2; ++i) {
00039 if (_t[i] != rhs._t[i]) return false;
00040 }
00041 return true;
00042 }
00043
00044 bool operator!=(const Tuple& rhs) const {
00045 return !(*this == rhs);
00046 }
00047
00048 void print(std::ostream& os) const {
00049 os << "(" << _t[0] << ", " << _t[1] << " id: " << _id << ")";
00050 }
00051 };
00052
00053 static inline std::ostream& operator<<(std::ostream& os, const Tuple& rhs) {
00054 rhs.print(os);
00055 return os;
00056 }
00057 #endif