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

FLL.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 _FLL_H
00014 #define _FLL_H
00015 
00016 #include <cstdlib>
00017 #include <cassert>
00018 #include <MemList.hpp>
00019 
00020 template <class Type> class FastList;
00021 
00022 template <class Type>
00023 class FLL {
00024 public:
00025 friend class FastList<Type>;
00026 
00027   FLL() : data(NULL), next(NULL) {} // default constructor
00028   FLL(Type &d) : data(&d), next(NULL) {}
00029   FLL(Type &d, FLL<Type> *pNext) : data(&d), next(pNext) {}
00030   ~FLL() {}                     // destructor does nothing, since using MemList
00031 
00032   FLL<Type> *Next() const { return next; }
00033   void Replace(Type &newData) { data = &newData; }
00034   Type &Data() const { return *data; }
00035 
00036 private:
00037   Type *data;                   // pointer to data at this node
00038   FLL<Type> *next;              // pointer to next node in list
00039 
00040   // Disallow these default operations
00041   FLL(const FLL &) { assert(0); }
00042   FLL &operator=(const FLL &) { assert(0); return *this; }
00043   int operator==(const FLL &x) const { return this == &x; }
00044 
00045 public:
00046   void *operator new(size_t size) { return pMemList->GetMem(size); }
00047   void operator delete(void *) { }
00048   static void UseMemory(MemList &memList) { pMemList = &memList; }
00049 
00050 private:
00051   static MemList *pMemList;
00052 };
00053 
00054 #endif

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