// -*- c-basic-offset: 4 -*- #ifndef CLICK_PAIR_HH #define CLICK_PAIR_HH #include #include CLICK_DECLS template struct Pair { typedef T first_type; typedef U second_type; typedef T key_type; typedef const T &key_const_reference; T first; U second; inline Pair() : first(), second() { } inline Pair(typename fast_argument::type t, typename fast_argument::type u) : first(t), second(u) { } inline Pair(const Pair &p) : first(p.first), second(p.second) { } template inline Pair(const Pair &p) : first(p.first), second(p.second) { } typedef hashcode_t (Pair::*unspecified_bool_type)() const; inline operator unspecified_bool_type() const { return first || second ? &Pair::hashcode : 0; } inline const T &hashkey() const { return first; } inline hashcode_t hashcode() const; template Pair &operator=(const Pair &p) { first = p.first; second = p.second; return *this; } }; template inline bool operator==(const Pair &a, const Pair &b) { return a.first == b.first && a.second == b.second; } template inline bool operator!=(const Pair &a, const Pair &b) { return a.first != b.first || a.second != b.second; } template inline bool operator<(const Pair &a, const Pair &b) { return a.first < b.first || (!(b.first < a.first) && a.second < b.second); } template inline hashcode_t Pair::hashcode() const { return (CLICK_NAME(hashcode)(first) << 7) ^ CLICK_NAME(hashcode)(second); } template inline Pair make_pair(T t, U u) { return Pair(t, u); } CLICK_ENDDECLS #endif