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

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

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