A template class for a hash pager.
More...
#include <memory.h>
Public Member Functions |
T * | begin (void) const |
| Find first typed object in hash map to iterate.
|
unsigned | count (void) const |
| Count the number of typed objects in our hash map.
|
T * | get (const char *name) const |
| Find a typed object derived from NamedObject in the hash map by name.
|
T ** | index (void) const |
| Convert our hash map into a linear object pointer array.
|
| keypager (size_t size) |
| Create the object cache.
|
T * | next (T *current) const |
| Find next typed object in hash map for iteration.
|
T * | operator[] (const char *name) const |
| Find a typed object derived from NamedObject in the hash map by name.
|
T ** | sort (void) const |
| Convert our hash map into an alphabetically sorted linear object pointer array.
|
bool | test (const char *name) const |
| Test if a name exists in the pool.
|
| ~keypager () |
| Destroy the hash pager by purging the index chains and memory pools.
|
virtual void * | _alloc (size_t size) |
| Allocate memory from the pager heap.
|
virtual void | dealloc (void *memory) |
| Return memory back to pager heap.
|
| mempager (size_t page=0) |
| Construct a memory pager.
|
void | purge (void) |
| Purge all allocated memory and heap pages immediately.
|
unsigned | utilization (void) |
| Determine fragmentation level of acquired heap pages.
|
virtual | ~mempager () |
| Destroy a memory pager.
|
unsigned | getAlloc (void) |
| Get the size of a memory page.
|
unsigned | getLimit (void) |
| Get the maximum number of pages that are permitted.
|
unsigned | getPages (void) |
| Get the number of pages that have been allocated from the real heap.
|
| memalloc (size_t page=0) |
| Construct a memory pager.
|
virtual | ~memalloc () |
| Destroy a memory pager.
|
void * | alloc (size_t size) |
| Convenience function.
|
char * | dup (const char *string) |
| Duplicate NULL terminated string into allocated memory.
|
void * | dup (void *memory, size_t size) |
| Duplicate existing memory block into allocated memory.
|
void * | zalloc (size_t size) |
| Allocate memory from the pager heap.
|
Additional Inherited Members |
virtual void | _lock (void) |
| Lock the memory pager mutex.
|
virtual void | _unlock (void) |
| Unlock the memory pager mutex.
|
unsigned | limit |
Detailed Description
template<class T, unsigned M = 177>
class ucommon::keypager< T, M >
A template class for a hash pager.
This creates objects from a pager pool when they do not already exist in the hash map.
- Author
- David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 1200 of file memory.h.
Constructor & Destructor Documentation
template<class T , unsigned M = 177>
Create the object cache.
- Parameters
-
Definition at line 1210 of file memory.h.
Member Function Documentation
template<class T , unsigned M = 177>
Find first typed object in hash map to iterate.
- Returns
- first typed object or NULL if nothing in list.
Definition at line 1254 of file memory.h.
template<class T , unsigned M = 177>
Count the number of typed objects in our hash map.
- Returns
- count of typed objects.
Definition at line 1269 of file memory.h.
template<class T , unsigned M = 177>
Find a typed object derived from NamedObject in the hash map by name.
If the object is not found, it is created from the memory pool.
- Parameters
-
- Returns
- typed object if found through map or NULL.
Definition at line 1224 of file memory.h.
template<class T , unsigned M = 177>
Convert our hash map into a linear object pointer array.
The object pointer array is created from the heap and must be deleted when no longer used.
- Returns
- array of typed named object pointers.
Definition at line 1278 of file memory.h.
template<class T , unsigned M = 177>
Find next typed object in hash map for iteration.
- Parameters
-
current | typed object we are referencing. |
- Returns
- next iterative object or NULL if past end of map.
Definition at line 1262 of file memory.h.
template<class T , unsigned M = 177>
Find a typed object derived from NamedObject in the hash map by name.
If the object is not found, it is created from the pager pool.
- Parameters
-
- Returns
- typed object if found through map or NULL.
Definition at line 1247 of file memory.h.
template<class T , unsigned M = 177>
Convert our hash map into an alphabetically sorted linear object pointer array.
The object pointer array is created from the heap and must be deleted when no longer used.
- Returns
- sorted array of typed named object pointers.
Definition at line 1287 of file memory.h.
template<class T , unsigned M = 177>
Test if a name exists in the pool.
- Parameters
-
- Returns
- true if found.
Definition at line 1238 of file memory.h.
The documentation for this class was generated from the following file: