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

MemCache.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 #ifndef _MEMCACHE_HPP
00013 #define _MEMCACHE_HPP
00014 
00022 /*
00023  *
00024  * NAME DATE - COMMENTS
00025  * tnt 11/2000 - created
00026  * tnt 03/2001 - mudge to lemur toolkit standards
00027  *
00028  * =====================================================================*/
00029 #include <cmath>
00030 #include "common_headers.hpp"
00031 
00032 #define MINPOW 5
00033 #define MAXPOW 22
00034 #define NLISTS MAXPOW-MINPOW+1
00035 
00036 class MemCache {
00037 public:
00041   MemCache(int cachesize);
00042 
00044   MemCache(int* cache, int cachesize);
00045 
00047   MemCache();
00048 
00052   ~MemCache();
00053 
00058   int* getMem(int chunksize);
00059 
00065   int* getMoreMem(int newsize, int* location, int oldsize);
00066 
00073   void freeMem(int* location, int memsize);
00074 
00078   void flushMem();
00079 
00080   const int* getBegin();
00081   const int* getEnd();
00082 
00083 private:
00089   int* getFromFree(int csize);
00090 
00091   int* begin;           
00092   int  size;            
00093   int* end;             
00094   int  intsize;         
00095   //vector<int*> freelist;      /// a list of free memory holes
00096   vector<int*> freelist[NLISTS]; 
00097   bool ourmem; 
00098 };
00099 
00100 #endif

Generated on Wed Nov 3 12:59:00 2004 for Lemur Toolkit by doxygen1.2.18