Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FreqVector.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2001 Carnegie Mellon University.  All Rights Reserved.
00003  *
00004  * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
00005  * is subject to the terms of the software license set forth in the LICENSE
00006  * file included with this software, and also available at
00007  * http://www.lemurproject.org/license.html
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 
00021 class FreqCount {
00022 public:
00023   TERMID_T key;
00024   unsigned int Hash() const { return ByteHash((char *)(&key),sizeof(TERMID_T),0); }
00025   unsigned int hash() const { return Hash(); }
00026   bool operator==(const FreqCount count) { return count.key == this->key;} 
00027 };
00028   
00031 
00032 class FreqVector {
00033 public:
00034 
00036   virtual bool find(TERMID_T ind, int &freq) const=0;
00037   virtual void startIteration()const=0;
00038   virtual bool hasMore()const=0;
00040   virtual void nextFreq(TERMID_T &id, int &freq)const=0;
00041   virtual int size()const=0;
00042 };
00043 
00044 
00046 class HashFreqVector : public FreqVector, public CSet<FreqCount, int> {
00047 public:
00048   HashFreqVector() : CSet<FreqCount, int>(300) {}
00050   HashFreqVector(const Index &index, DOCID_T docID);
00051 
00052   virtual ~HashFreqVector() {};
00053 
00054   
00055   virtual bool find(DOCID_T ind, int &freq)const ;
00056 
00057   virtual void startIteration() const {  i=0; }
00058   virtual bool hasMore() const {  return (i < size()); }
00059   virtual void nextFreq(DOCID_T &id, int &freq)const ;
00060 
00062   virtual int size() const {    return (ISet<FreqCount>::size()); }
00063 protected:
00064   mutable int i;
00065 };
00066 
00067 #endif /* _FREQVECTOR_HPP */
00068 
00069 
00070 
00071 
00072 
00073 
00074 

Generated on Wed Nov 3 12:58:55 2004 for Lemur Toolkit by doxygen1.2.18