00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _FLOATFREQVECTOR_HPP
00014 #define _FLOATFREQVECTOR_HPP
00015
00016 #include "FreqVector.hpp"
00017
00019 class FloatFreqCounter {
00020 public:
00021 TERMID_T key;
00022
00023 unsigned int Hash() const { return (unsigned int)key; }
00024 unsigned int hash() const { return Hash(); }
00025 bool operator==(const FloatFreqCounter count) { return count.key == this->key;}
00026 };
00027
00028 class FloatFreqVector : public FreqVector, public CSet<FloatFreqCounter, double> {
00029 public:
00030 FloatFreqVector() : CSet<FloatFreqCounter, double>(1000) {s2 = 0;}
00032 FloatFreqVector(const Index &index, DOCID_T docID);
00033 FloatFreqVector(const Index &index, TermInfoList *tList);
00034 FloatFreqVector(const Index &index, vector<DOCID_T> &dids);
00035 FloatFreqVector(FloatFreqVector *old);
00036
00037 virtual ~FloatFreqVector() {};
00038 virtual bool find(TERMID_T ind, double &freq) const;
00039 virtual void startIteration() const { i=0; }
00040 virtual bool hasMore() const { return (i < size()); }
00041 virtual void nextFreq(TERMID_T &id, double &freq) const;
00043 virtual int size() const { return (ISet<FloatFreqCounter>::size()); }
00044
00045 virtual void nextFreq (TERMID_T &id, int &freq) const;
00046 virtual bool find(TERMID_T ind, int &freq) const ;
00047
00048 void addVal(TERMID_T id, int cnt);
00049 void addVal(TERMID_T id, double val);
00050 double sum() const;
00051 double sum2() const;
00052 void weigh(const double *vals);
00053 void weigh(double vals);
00054 void addVec(const FloatFreqVector *v2);
00055 void subtract(const FloatFreqVector *v2);
00056 double dotProd(const FloatFreqVector *v2);
00057
00058 protected:
00059 mutable int i;
00060 mutable double s2;
00061
00062 };
00063
00064 #endif