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

IndexProb.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 _INDEXPROB_
00014 #define _INDEXPROB_
00015 
00016 
00018 
00019 
00027 // J. Lafferty, 10/00
00028 //
00029 //---------------------------------------------------------------
00030 
00031 
00032 
00033 #include <cstdio>
00034 #include "MemList.hpp"
00035 #include "common_headers.hpp"
00036 
00037 class IndexProb
00038 {
00039 public:
00040   IndexProb() : index(0), prob(0) {};
00041   IndexProb(int id, double ct) : index(id), prob(ct) {}
00042   IndexProb(IndexProb &dc) : index(dc.index), prob(dc.prob) {}
00043   IndexProb &operator=(const IndexProb &that)
00044     { index=that.index; prob=that.prob; return *this; }
00045   int operator==(const IndexProb &that) const
00046     { return ((index==that.index) && (prob==that.prob)); }
00047   int operator!=(const IndexProb &that) const
00048     { return ((index!=that.index) || (prob!=that.prob)); }
00049   int operator>(const IndexProb &that) const { return prob > that.prob; }
00050   void read(ifstream &ifs) { 
00051     ifs.read((char *)&index, sizeof(int));
00052     ifs.read((char *)&prob, sizeof(double));
00053   }
00054   void write(ofstream &ofs) const { 
00055     ofs.write((char *)&index, sizeof(int));
00056     ofs.write((char *)&prob, sizeof(double));
00057   }
00058 
00059 public:
00060   int index;
00061   double prob;
00062 
00063 // Sorting routines -- quicksort using random pivoting
00064 public:
00065   static int rqSort(int n, IndexProb * ic);
00066 
00067 private:
00068   static void insertionsort(IndexProb * a, int n);
00069   static void rquicksort(IndexProb * a, int n);
00070 
00071 public:
00072   // Memory management
00073   void *operator new(size_t size) { return pMemList->GetMem(size); }
00074   void operator delete(void *) { }
00075   static void UseMemory(MemList &memList);
00076 
00077 private:
00078   static MemList *pMemList;
00079 
00080 };
00081 
00082 #endif
00083 

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