#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Core/Container/Misc/Tuple2.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVL_TUPLE2_HEADER #define RAVL_TUPLE2_HEADER 1 ///////////////////////////////////////////////// //! rcsid="$Id: Tuple2.hh,v 1.3 2002/05/21 14:46:11 craftit Exp $" //! docentry="Ravl.Core.Tuples" //! userlevel=Normal //! file="Ravl/Core/Container/Misc/Tuple2.hh" //! lib=RavlCore //! author="Charles Galambos" //! date="09/06/98" #include "Ravl/Types.hh" namespace RavlN { class BinIStreamC; class BinOStreamC; //: Class containing two other arbitrary classes template class Tuple2C { public: Tuple2C() {} //: Default constructor. Tuple2C(const T1 &nd1,const T2 &nd2) : d1(nd1), d2(nd2) {} //: Constructor. Tuple2C(const Tuple2C &oth) : d1(oth.d1), d2(oth.d2) {} //: Copy constructor. T1 &Data1() { return d1; } //: Data access. const T1 &Data1() const { return d1; } //: Data access. T2 &Data2() { return d2; } //: Data access. const T2 &Data2() const { return d2; } //: Data access. UIntT Hash() const { UIntT h2 = StdHash(d2); return (StdHash(d1) + h2) ^ (h2 << 7); } //: Get hash value for tuple. bool operator==(const Tuple2C &oth) const { return (oth.d1 == d1) && (oth.d2 == d2); } //: Are tuples equal ? bool operator!=(const Tuple2C &oth) const { return (oth.d1 != d1) || (oth.d2 != d2);} //: Are tuples unequal ? protected: T1 d1; T2 d2; }; template ostream &operator<<(ostream &out,const Tuple2C &obj) { out << obj.Data1() << ' ' << obj.Data2() << ' '; return out; } template istream &operator>>(istream &in,Tuple2C &obj) { in >> obj.Data1() >> obj.Data2(); return in; } // Binary stream operators. template BinOStreamC &operator<<(BinOStreamC &out,const Tuple2C &obj) { out << obj.Data1() << obj.Data2(); return out; } template BinIStreamC &operator>>(BinIStreamC &in,Tuple2C &obj) { in >> obj.Data1() >> obj.Data2(); return in; } } #endif