00001 #ifndef DEF_LISTTUPEL
00002 #define DEF_LISTTUPEL
00003 #include "IndexingException.h"
00004
00005 #pragma warning( disable : 4786 )
00006
00007 namespace groupindex
00008 {
00009
00019 template<class Group>
00020 class ListTupel
00021
00022 {
00023
00024 public:
00025
00026
00028 Group g;
00029
00031 int i;
00032
00033
00034 int credit;
00035
00037 ListTupel()
00038 {
00039 };
00040
00042 ListTupel(const Group& g0, const int i0)
00043 {
00044 g = g0;
00045 i = i0;
00046 };
00047
00049 bool operator==(const ListTupel<Group>& lt1) const
00050 {
00051 return (i==lt1.i && g==lt1.g);
00052 };
00053
00055 int operator<(const ListTupel<Group>& lt2) const
00056 {
00057 return ((*this).i<lt2.i || ((*this).i==lt2.i && (*this).g<lt2.g));
00058 };
00059
00061 int operator>(const ListTupel<Group>& lt2) const
00062 {
00063 if ((*this)<lt2 || (*this)==lt2)
00064 return false;
00065 return true;
00066 };
00067
00068 friend std::ofstream& operator<<(std::ofstream& ofs, ListTupel<Group>& lt)
00069 {
00070
00071 ofs<<lt.g;
00072 ofs.write((char*)&(lt.i),sizeof(int));
00073 return ofs;
00074
00075 }
00076
00077
00078 friend std::fstream& operator<<(std::fstream& ofs, ListTupel<Group>& lt);
00079
00080 friend std::ifstream& operator>>(std::ifstream& ifs, ListTupel<Group>& lt)
00081 {
00082
00083 ifs>>lt.g;
00084 ifs.read((char*)&(lt.i),sizeof(int));
00085 return ifs;
00086
00087 }
00088
00089
00090 friend std::fstream& operator>>(std::fstream& fs, ListTupel<Group>& lt);
00091
00092
00093
00094
00095
00096
00097
00098
00099 inline long size() const
00100 {
00101 return g.size() + sizeof(int);
00102 }
00103
00104 };
00105
00106 template<class Group>
00107 std::fstream& operator>>(std::fstream& fs, ListTupel<Group>& lt)
00108 {
00109 fs>>lt.g;
00110 fs.read((char*)&(lt.i),sizeof(int));
00111 return fs;
00112 }
00113
00114 template<class Group>
00115 std::fstream& operator<<(std::fstream& ofs, ListTupel<Group>& lt)
00116 {
00117 ofs<<lt.g;
00118 ofs.write((char*)&(lt.i),sizeof(int));
00119 return ofs;
00120 }
00121
00122 }
00123
00124 #endif