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