#include <opennurbs_fsp.h>
◆ ON_FixedSizePoolIterator() [1/2]
ON_FixedSizePoolIterator::ON_FixedSizePoolIterator |
( |
| ) |
|
◆ ON_FixedSizePoolIterator() [2/2]
ON_FixedSizePoolIterator::ON_FixedSizePoolIterator |
( |
const class ON_FixedSizePool & |
fsp | ) |
|
◆ Create()
◆ CurrentElement()
void* ON_FixedSizePoolIterator::CurrentElement |
( |
| ) |
const |
◆ FirstBlock()
void* ON_FixedSizePoolIterator::FirstBlock |
( |
size_t * |
block_element_count | ) |
|
Get a pointer to the first element in the first block.
- Parameters
-
block_element_count | [out] (can be null) If not null, the number of elements allocated from the first block is returned in block_element_count. Note that if you have used ReturnElement(), some of these elemements may have been returned. |
- Returns
- The first block when iterating the list of blocks.
The heap for a fixed size memory pool is simply a linked list of blocks. FirstBlock() and NextBlock() can be used to iterate through the list of blocks.
Do not make any calls to FirstElement() or NextElement() when using FirstBlock() and NextBlock() to iteratate through blocks.
The loop will iteratate through all the blocks.
@verbatim
size_t block_element_count = 0;
0 != p;
)
{
ElementType* e = (ElementType*)p;
for ( size_t i = 0;
i < block_element_count;
i++, e = ((const char*)e) + SizeofElement()
)
{
...
}
}
@endverbatim
◆ FirstElement() [1/2]
void* ON_FixedSizePoolIterator::FirstElement |
( |
| ) |
|
Get the first element when iterating through the list of elements.
- Parameters
-
element_index | [in] If you use the version of FirstElement() that has an element_index parameter, then the iteration begins at that element. |
- Returns
- The first element when iterating through the list of elements.
FirstElement() and NextElement() will return elements that have been returned to the pool using ReturnElement(). If you use ReturnElement(), then be sure to mark the element so it can be identified and skipped.
Do not make any calls to FirstBlock() or NextBlock() when using FirstElement() and NextElement() to iteratate through elements.
The loop will iteratate through all the elements returned from
AllocateElement(), including any that have be returned to the pool
using ReturnElement().
@verbatim
{
if ( p is not active )
continue;
... process p
}
@endverbatim
◆ FirstElement() [2/2]
void* ON_FixedSizePoolIterator::FirstElement |
( |
size_t |
element_index | ) |
|
◆ FixedSizePool()
◆ NextBlock()
void* ON_FixedSizePoolIterator::NextBlock |
( |
size_t * |
block_element_count | ) |
|
Get the next block when iterating through the blocks.
- Parameters
-
block_element_count | [out] (can be null) If not null, the number of elements allocated from the block is returned in block_element_count. Note that if you have used ReturnElement(), some of these elemements may have been returned. |
- Returns
- The next block when iterating through the blocks.
Do not make any calls to FirstElement() or NextElement() when using FirstBlock() and NextBlock() to iteratate through blocks.
◆ NextElement()
void* ON_FixedSizePoolIterator::NextElement |
( |
| ) |
|
Get the next element when iterating through the list of elements. If FirstElement() is not called, then the first call to NextElement() returns the first element.
- Returns
- The next element when iterating through the list of elements.
FirstElement() and NextElement() will return elements that have been returned to the pool using ReturnElement(). If you use ReturnElement(), then be sure to mark the element so it can be identified and skipped.
Do not make any calls to FirstBlock() or NextBlock() when using FirstElement() and NextElement() to iteratate through elements.
◆ Reset()
void ON_FixedSizePoolIterator::Reset |
( |
| ) |
|
Sets the state of the iterator to the initial state that exists after construction. This is useful if the iterator has been used the get one or more elements and then the referenced fixed size pool is modified or code wants to begin iteration again a used a call to NextElement() to return the first element.