00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _FREQVECTOR_HPP
00014 #define _FREQVECTOR_HPP
00015
00016 #include "ByteHash.hpp"
00017 #include "Index.hpp"
00018 #include "CSet.hpp"
00019 namespace lemur
00020 {
00021 namespace utility
00022 {
00023
00025 class FreqCount {
00026 public:
00027 lemur::api::TERMID_T key;
00028 unsigned int Hash() const { return ByteHash((char *)(&key),sizeof(lemur::api::TERMID_T),0); }
00029 unsigned int hash() const { return Hash(); }
00030 bool operator==(const FreqCount count) { return count.key == this->key;}
00031 };
00032
00035
00036 class FreqVector {
00037 public:
00038
00040 virtual bool find(lemur::api::TERMID_T ind, int &freq) const=0;
00041 virtual void startIteration()const=0;
00042 virtual bool hasMore()const=0;
00044 virtual void nextFreq(lemur::api::TERMID_T &id, int &freq)const=0;
00045 virtual int size()const=0;
00046 };
00047
00048
00050 class HashFreqVector : public FreqVector, public CSet<FreqCount, int> {
00051 public:
00052 HashFreqVector() : CSet<FreqCount, int>(300) {}
00054 HashFreqVector(const lemur::api::Index &index, lemur::api::DOCID_T docID);
00055
00056 virtual ~HashFreqVector() {};
00057
00058
00059 virtual bool find(lemur::api::DOCID_T ind, int &freq)const ;
00060
00061 virtual void startIteration() const { i=0; }
00062 virtual bool hasMore() const { return (i < size()); }
00063 virtual void nextFreq(lemur::api::DOCID_T &id, int &freq)const ;
00064
00066 virtual int size() const { return (ISet<FreqCount>::size()); }
00067 protected:
00068 mutable int i;
00069 };
00070 }
00071 }
00072
00073 #endif