Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class 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 
00015 /*
00016  *
00017  * NAME DATE - COMMENTS
00018  * tnt 11/2000 - created
00019  * tnt 03/2001 - mudge to lemur toolkit standards
00020  *
00021  * =====================================================================*/
00022 #include <cmath>
00023 #include "common_headers.hpp"
00024 
00025 #define MINPOW 5
00026 #define MAXPOW 22
00027 #define NLISTS MAXPOW-MINPOW+1
00028 namespace lemur 
00029 {
00030   namespace utility
00031   {
00032     
00039     class MemCache {
00040     public:
00044       MemCache(int cachesize);
00045 
00047       MemCache(int* cache, int cachesize);
00048 
00050       MemCache();
00051 
00055       ~MemCache();
00056 
00061       int* getMem(int chunksize);
00062 
00068       int* getMoreMem(int newsize, int* location, int oldsize);
00069 
00076       void freeMem(int* location, int memsize);
00077 
00081       void flushMem();
00082 
00083       const int* getBegin();
00084       const int* getEnd();
00085 
00086     private:
00092       int* getFromFree(int csize);
00093 
00094       int* begin;               
00095       int  size;                
00096       int* end;         
00097       int  intsize;             
00098       //vector<int*> freelist;  /// a list of free memory holes
00099       vector<int*> freelist[NLISTS]; 
00100       bool ourmem; 
00101     };
00102   }
00103 }
00104 
00105 #endif

Generated on Tue Jun 15 11:02:54 2010 for Lemur by doxygen 1.3.4