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

BasicDocInfoList.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 _BASICDOCINFOLIST_HPP
00014 #define _BASICDOCINFOLIST_HPP
00015 
00016 #include "DocInfoList.hpp"
00017 
00018 
00020 
00021 class BasicDocInfo : public DocInfo {
00022 public:
00023   BasicDocInfo() {}
00024   BasicDocInfo( int docID, int termCount) : 
00025     id(docID), count(termCount) {}
00026   virtual int termCount() { return count;}
00027 
00028   virtual int docID() { return id;}
00029   friend class BasicDocInfoList;
00030 private:
00031   int id, count;
00032 };
00033 
00034 
00036 
00037 class BasicDocInfoList : public DocInfoList {
00038 public:
00039   BasicDocInfoList(int *tmpDocArray, int size);
00040 
00041   virtual ~BasicDocInfoList() {}
00042   virtual void startIteration() {
00043     it = 0;
00044     prevDocID = 0;
00045   }
00046 
00047   virtual bool hasMore() { return (it<sz); }
00048 
00049   virtual DocInfo * nextEntry();
00050 
00051 
00052 private:
00053   int sz, it, prevDocID;
00054   int *tmpdarr;
00055 };
00056 
00057 
00058 inline BasicDocInfoList::BasicDocInfoList(int *tmpDocArray, int size):
00059   tmpdarr(tmpDocArray), sz(size), it(0), prevDocID(0) 
00060 {
00061 }
00062 
00064 inline DocInfo * BasicDocInfoList::nextEntry() {
00065   // assert (hasMore());
00066   static BasicDocInfo info;
00067   info.id =  tmpdarr[it]+prevDocID;
00068   prevDocID = info.id;
00069   info.count = tmpdarr[sz+it];
00070   it++;
00071   return (&info);
00072 }
00073 
00074 #endif
00075 
00076 

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