Main Page   Namespace List   Class Hierarchy   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.cs.cmu.edu/~lemur/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   int key;
00024   unsigned int Hash() const { return ByteHash((char *)(&key),sizeof(int),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(int ind, int &freq)=0;
00037   virtual void startIteration()=0;
00038   virtual bool hasMore()=0;
00040   virtual void nextFreq(int &id, int &freq)=0;
00041   virtual int size()=0;
00042 };
00043 
00044 
00046 class HashFreqVector : public FreqVector, public CSet<FreqCount, int> {
00047 public:
00048   HashFreqVector() : CSet<FreqCount, int>(300) {}
00050   HashFreqVector(Index &index, int docID);
00051 
00052   virtual ~HashFreqVector() {};
00053 
00054   
00055   virtual bool find(int ind, int &freq);
00056 
00057   virtual void startIteration() {  i=0; }
00058   virtual bool hasMore() {  return (i < size()); }
00059   virtual void nextFreq(int &id, int &freq);
00060 
00062   virtual int size() {    return (ISet<FreqCount>::size()); }
00063 protected:
00064   int i;
00065 };
00066 
00067 #endif /* _FREQVECTOR_HPP */
00068 
00069 
00070 
00071 
00072 
00073 
00074 

Generated at Fri Jul 26 18:22:26 2002 for LEMUR by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000