00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _DOCSCORE_HPP
00014 #define _DOCSCORE_HPP
00015
00017
00025 #include "common_headers.hpp"
00026 #include <algorithm>
00027 #include <string>
00028 struct DocScore {
00029 double val;
00030 string id;
00031 };
00032
00033
00034 class DocScoreVector : public vector<DocScore> {
00035 public:
00036
00037 DocScoreVector() : vector<DocScore>() {}
00038 DocScoreVector(int size) : vector<DocScore>(size) {}
00039 virtual ~DocScoreVector();
00040
00042 virtual void PushValue(const string &docid, double value);
00043
00045 virtual void Sort(bool descending = true);
00046 private:
00047
00050
00051 class ScoreAscending {
00052 public:
00053 bool operator()(const DocScore & a, const DocScore & b) {
00054 return a.val < b.val;
00055 }
00056 };
00057
00058 class ScoreDescending {
00059 public:
00060 bool operator()(const DocScore & a, const DocScore & b) {
00061 return a.val > b.val;
00062 }
00063 };
00064
00065 static ScoreAscending ascendOrder;
00066 static ScoreDescending descendOrder;
00067
00068 };
00069
00070
00071
00072 #endif
00073
00074
00075
00076
00077