#include "mempool.h"#include "erglob.h"#include "errors.h"


Go to the source code of this file.
Data Types | |
| module | DYN_ARRAY< T > |
| module | STACK< T > |
Defines | |
| #define | cxx_template_INCLUDED "cxx_template.h" |
| #define | MIN_ARRAY_SIZE 16 |
Functions/Subroutines | |
| template<class CONTAINER, class PREDICATE> | |
| void | Remove_if (CONTAINER &container, PREDICATE pred) |
| #define cxx_template_INCLUDED "cxx_template.h" |
==================================================================== ====================================================================
Module: cxx_template.h
Revision history: 8-SEP-94 shin - Original Version
Description:
This interface describes the DYN_ARRAY template for dynamic array and the STACK template which uses an dynamic array to implement the stack.
The size of the array can grow dynamically. The subscript operator is overloaded such that it appear to the user is the same as any ordinary array. Internally, the subscript index must be less than the array size and less equal to the allocated index. As the result, user must call Newidx to allocate an array element. Once an index is allocated, it can be used with subscript operator.
Reserver Prefixes:
None.
Exported Types:
None.
Exported Functions:
DYN_ARRAY(MEM_POOL *pool)
Construct a dynamic array using the MEM_POOL *pool. This memory pool will be used in future allocation, reallocation and free of this dynamic array.
~DYN_ARRAY(void)
Destruct this dynamic array and free the space if necessary.
void Set_Mem_Pool(MEM_POOL* mpool)
Set the memory pool for future memory allocation to be mpool. This should be used only in places where DYN_ARRAY(MEM_POOL *pool) cannot be used, e.g., array of dynamic arrays.
void Alloc_array(mUINT32 arr_size)
Allocate an array of size max(arr_size, MIN_ARRAY_SIZE)
void Force_Alloc_array(mUINT32 arr_size)
Allocate an array of size max(arr_size, 1)
void Realloc_array(mUINT32 new_size)
Re-allocate array for size 'new_size'.
void Free_array(void)
Free the space to the memory pool and re-set the index.
void Bzero_array(void)
Clear (fill with 0) the array at its current size
DYN_ARRAY& operator = (const DYN_ARRAY& a)
The size and the index of the input dynamic array 'a' is copied to the current array. Using own memory pool, the array re-allocate space in order to change to have the same size as 'a'.
T& operator[] (mUINT32 idx) const T& operator[] (mUINT32 idx) T& Get(mUINT32 idx) const void Set(mUINT32 idx, const T& val)
void AddElement (const T& val) Grow the array by 1 element and add val at the end of the array.
mUINT32 Elements () const Return the number of elements in the array, useful for iterating over all the elements.
Access the element 'idx'.
mUINT32 Newidx(void)
Allocate a new index. It controls whether re-allocation is needed. If an index is returned from Newidx(), it is sure to be valid.
Note: although the space is allocated for the returned index, the data is NOT initialized.
void Decidx(void)
Decrement the last index pointer by one which essentially makes the last index available for Newidx() again.
void Initidx(UINT32 idx)
Set the last index pointer to 'idx'. Allocate more space if necessary but no copying is done.
void Setidx(UINT32 idx)
Set the last index pointer to 'idx'. Allocate more space if necessary and old contents are copied.
void Resetidx(void)
Set the last index pointer to -1 and the whole array are available starting from the first ('0'-th) element.
mUINT32 Sizeof(void) const
Return the current size of the array.
mINT32 Lastidx(void) const
Return the current value of the last index pointer.
==================================================================== ====================================================================
Definition at line 170 of file cxx_template.h.
| #define MIN_ARRAY_SIZE 16 |
Definition at line 353 of file cxx_template.h.
| void Remove_if | ( | CONTAINER & | container, | |
| PREDICATE | pred | |||
| ) | [inline] |
Description:
Remove_if takes a predicate struct and removes an item from the container if pred(item) returns TRUE.
An example predicate:
struct Predicate { BOOL operator()(EXP_WORKLST *wk) { return wk->Real_occurs().Head() == NULL; }; }
Definition at line 533 of file cxx_template.h.
References next, NULL, and prev.
Referenced by SSU::Construct().
1.5.6