Create a new queue structure
#include "dip_pixelqueue.h"
dip_Error dip_PixelQueueNew ( queue, ndims, blocksize, resources )
This function allocates space for a new dip_PixelQueue structure. Memory allocated is tracked in resources. The queue is dimensioned to hold pixels from an ndims-dimensional image, and initially enough space is allocated for blocksize elements. The queue will be expanded as necessary when used.
The queue stores the coordinates, and the pointer to a pixel in an image. ndims can be set to zero, in which case no coordinates are stored; this does not affect the function of the pointer.
A queue is a data structure to which items can be added (pushed) to the back, and subtracted (popped) from the front (FIFO - First In, First Out).
Data type | Name | Description |
dip_PixelQueue * | queue | The newly allocated queue structure |
dip_int | ndims | Image dimensionality |
dip_int | blocksize | Size of each allocation block |
dip_Resources | resources | Resources tracking structure. See ResourcesNew |
The queue is stored in an array whose size can be incresed at will. This is accomplished by a linked list of blocks, each one holds blocksize elements. When more space is needed, a new block is simply allocated. No data needs to be moved as would be necessary when using realloc to change the size of the array. Blocks on the front of the queue that become empty are freed.
PixelHeapNew, StablePixelHeapNew, PixelQueueFree, PixelQueuePush, PixelQueuePop, PixelQueueIsEmpty