00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _INDEXCOUNTH_
00014 #define _INDEXCOUNTH_
00015
00017
00025
00026
00027
00028
00029
00030 #include "common_headers.hpp"
00031 #include <cstdlib>
00032 #include "MemList.hpp"
00033
00034 class IndexCount
00035 {
00036 public:
00037 IndexCount() : index(0), count(0) {};
00038 IndexCount(int id, int ct) : index(id), count(ct) {}
00039 IndexCount(IndexCount &dc) : index(dc.index), count(dc.count) {}
00040 IndexCount &operator=(const IndexCount &that)
00041 { index=that.index; count=that.count; return *this; }
00042 int operator==(const IndexCount &that) const
00043 { return ((index==that.index) && (count==that.count)); }
00044 int operator!=(const IndexCount &that) const
00045 { return ((index!=that.index) || (count!=that.count)); }
00046 int operator>(const IndexCount &that) const { return count > that.count; }
00047 void read(ifstream &ifs) {
00048 ifs.read((char *)&index, sizeof(int));
00049 ifs.read((char *)&count, sizeof(int));
00050 }
00051 void write(ofstream &ofs) const {
00052 ofs.write((char *)&index, sizeof(int));
00053 ofs.write((char *)&count, sizeof(int));
00054 }
00055
00056 public:
00057 int index;
00058 int count;
00059
00060
00061 public:
00062 static int rqSort(int n, IndexCount * ic);
00063
00064 private:
00065 static void insertionsort(IndexCount * a, int n);
00066 static void rquicksort(IndexCount * a, int n);
00067
00068 public:
00069
00070 void *operator new(size_t size) { return pMemList->GetMem(size); }
00071 void operator delete(void *) { }
00072 static void UseMemory(MemList &memList);
00073
00074 private:
00075 static MemList *pMemList;
00076
00077 };
00078
00079 #endif
00080