Rhino C++ API  8.14
Public Member Functions | List of all members
ON_FixedSizePoolIterator Class Reference

#include <opennurbs_fsp.h>

Inheritance diagram for ON_FixedSizePoolIterator:
ON_MeshXPointPoolIterator ON_SimpleFixedSizePoolIterator< T > ON_SubDEdgeIdIterator ON_SubDFaceIdIterator ON_SubDVertexIdIterator

Public Member Functions

 ON_FixedSizePoolIterator ()
 
 ON_FixedSizePoolIterator (const class ON_FixedSizePool &fsp)
 
void Create (const ON_FixedSizePool *fsp)
 
void * CurrentElement () const
 
void * FirstBlock (size_t *block_element_count)
 
void * FirstElement ()
 
void * FirstElement (size_t element_index)
 
const class ON_FixedSizePoolFixedSizePool ()
 
void * NextBlock (size_t *block_element_count)
 
void * NextElement ()
 
void Reset ()
 

Constructor & Destructor Documentation

◆ ON_FixedSizePoolIterator() [1/2]

ON_FixedSizePoolIterator::ON_FixedSizePoolIterator ( )

◆ ON_FixedSizePoolIterator() [2/2]

ON_FixedSizePoolIterator::ON_FixedSizePoolIterator ( const class ON_FixedSizePool fsp)

Member Function Documentation

◆ Create()

void ON_FixedSizePoolIterator::Create ( const ON_FixedSizePool fsp)

◆ CurrentElement()

void* ON_FixedSizePoolIterator::CurrentElement ( ) const

Returns: The most recently returned value from a call to FirstElement() or NextElement(). Remarks: Do not make any calls to FirstBlock() or NextBlock() when using FirstElement() and NextElement() to iterate through elements.

◆ FirstBlock()

void* ON_FixedSizePoolIterator::FirstBlock ( size_t *  block_element_count)

Description: 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 elements may have been returned. Example: The loop will iterate through all the blocks.

/ iterate through all blocks in the pool size_t block_element_count = 0; for ( void* p = FirstBlock(&block_element_count); 0 != p; p = NextBlock(&block_element_count) ) { ElementType* e = (ElementType*)p; for ( size_t i = 0; i < block_element_count; i++, e = ((const char*)e) + SizeofElement() ) { ... } }

Returns: The first block when iterating the list of blocks. Remarks: 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 iterate through blocks.

◆ FirstElement() [1/2]

void* ON_FixedSizePoolIterator::FirstElement ( )

Description: 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. Example: The loop will iterate through all the elements returned from AllocateElement(), including any that have be returned to the pool using ReturnElement().

/ iterate through all elements in the pool / This iteration will go through TotalElements() items. for ( void* p = FirstElement(); 0 != p; p = NextElement() ) { / If you are not using ReturnElement(), then you may process / "p" immediately. If you have used ReturnElement(), then you / must check some value in p located after the first sizeof(void*) / bytes to see if p is active. if ( p is not active ) continue;

... process p }

Returns: The first element when iterating through the list of elements. Remarks: 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 iterate through elements.

◆ FirstElement() [2/2]

void* ON_FixedSizePoolIterator::FirstElement ( size_t  element_index)

◆ FixedSizePool()

const class ON_FixedSizePool* ON_FixedSizePoolIterator::FixedSizePool ( )

◆ NextBlock()

void* ON_FixedSizePoolIterator::NextBlock ( size_t *  block_element_count)

Description: 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 elements may have been returned. Example: See the FirstBlock() documentation. Returns: The next block when iterating through the blocks. Remarks: Do not make any calls to FirstElement() or NextElement() when using FirstBlock() and NextBlock() to iterate through blocks.

◆ NextElement()

void* ON_FixedSizePoolIterator::NextElement ( )

Description: 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. Example: See the FirstElement() documentation. Returns: The next element when iterating through the list of elements. Remarks: 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 iterate through elements.

◆ Reset()

void ON_FixedSizePoolIterator::Reset ( )

Description: 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.