X-Git-Url: https://git.auder.net/?p=cgds.git;a=blobdiff_plain;f=src%2FPriorityQueue.h;fp=src%2FPriorityQueue.h;h=01b7789019025581f164106dfaaaa7a56db31f06;hp=59fe5110f04653b2a7cae6c65bec9a42f78a454c;hb=e45132acdb58c076d5e06849fa51c26de9a7486d;hpb=1ff641f9960fa6c6081817a5641afb22fad91dcd diff --git a/src/PriorityQueue.h b/src/PriorityQueue.h index 59fe511..01b7789 100644 --- a/src/PriorityQueue.h +++ b/src/PriorityQueue.h @@ -15,16 +15,16 @@ * @brief Priority queue data structure (wrapper around Heap). */ typedef struct PriorityQueue { - Heap* heap; ///< Internal heap. + Heap* heap; ///< Internal heap. } PriorityQueue; /** * @brief Return an allocated and initialized Queue. */ PriorityQueue* _priorityqueue_new( - size_t dataSize, ///< Size in bytes of a priority queue element. - OrderType pType, ///< Type of priority queue: max or min first (MAX_T or MIN_T). - UInt arity ///< Arity of the wrapped heap: any integer >=2. + size_t dataSize, ///< Size in bytes of a priority queue element. + OrderType pType, ///< Type of priority queue: max or min first (MAX_T or MIN_T). + UInt arity ///< Arity of the wrapped heap: any integer >=2. ); /** @@ -33,31 +33,32 @@ PriorityQueue* _priorityqueue_new( * @param pType type of priority queue: max or min first (MAX_T or MIN_T). * @param arity Arity of the wrapped heap: any integer >=2. * - * Usage: PriorityQueue* priorityqueue_new(\ - * type, OrderType pType, UInt arity) + * Usage: PriorityQueue* priorityqueue_new( type, OrderType pType, UInt arity) */ #define priorityqueue_new(type, pType, arity) \ - _priorityqueue_new(sizeof(type), pType, arity) +{ \ + _priorityqueue_new(sizeof(type), pType, arity); \ +} /** * @brief Copy constructor (shallow copy, ok for basic types). */ PriorityQueue* priorityqueue_copy( - PriorityQueue* priorityQueue ///< "this" pointer. + PriorityQueue* priorityQueue ///< "this" pointer. ); /** * @brief Check if the priority queue is empty. */ bool priorityqueue_empty( - PriorityQueue* priorityQueue ///< "this" pointer. + PriorityQueue* priorityQueue ///< "this" pointer. ); /** * @brief Return the size of current priority queue. */ UInt priorityqueue_size( - PriorityQueue* priorityQueue ///< "this" pointer. + PriorityQueue* priorityQueue ///< "this" pointer. ); /** @@ -66,11 +67,10 @@ UInt priorityqueue_size( * @param item Item to be added. * @param priority Priority of the added item. * - * Usage: void priorityqueue_insert(\ - * PriorityQueue* priorityQueue, void item, Real priority) + * Usage: void priorityqueue_insert(PriorityQueue* priorityQueue, void item, Real priority) */ #define priorityqueue_insert(priorityQueue, item, priority) \ - heap_insert(priorityQueue->heap, item, priority) + heap_insert(priorityQueue->heap, item, priority) /** * @brief Change the priority of an item in the queue. @@ -79,11 +79,10 @@ UInt priorityqueue_size( * @param newPriority New priority of the modified item. * @note If several similar items are present, only the first is affected. * - * Usage: void priorityqueue_set_priority(\ - * PriorityQueue* priorityQueue, void item, Real newPriority) + * Usage: void priorityqueue_set_priority(PriorityQueue* priorityQueue, void item, Real newPriority) */ #define priorityqueue_set(priorityQueue, item, newPriority) \ - heap_modify(priorityQueue->heap, item, newPriority) + heap_modify(priorityQueue->heap, item, newPriority) /** * @brief Remove an item in the queue. @@ -94,14 +93,14 @@ UInt priorityqueue_size( * Usage: void priorityqueue_remove(PriorityQueue* priorityQueue, void item) */ #define priorityqueue_remove(priorityQueue, item) \ - heap_remove(priorityQueue->heap, item) + heap_remove(priorityQueue->heap, item) /** * @brief Return what is at the beginning of the queue. * @return An ItemValue* 'iv' with iv->item = data, and iv->value its priority. */ ItemValue* priorityqueue_peek_raw( - PriorityQueue* priorityQueue ///< "this" pointer. + PriorityQueue* priorityQueue ///< "this" pointer. ); /** @@ -112,27 +111,27 @@ ItemValue* priorityqueue_peek_raw( * Usage: void priorityqueue_peek(PriorityQueue* priorityQueue, void item) */ #define priorityqueue_peek(priorityQueue, item) \ - heap_top(priorityQueue->heap, item) + heap_top(priorityQueue->heap, item) /** * @brief Remove the top element in the queue. */ void priorityqueue_pop( - PriorityQueue* priorityQueue ///< "this" pointer. + PriorityQueue* priorityQueue ///< "this" pointer. ); /** * @brief Clear the entire queue. */ void priorityqueue_clear( - PriorityQueue* priorityQueue ///< "this" pointer. + PriorityQueue* priorityQueue ///< "this" pointer. ); /** * @brief Destroy the queue: clear it and free 'priorityQueue' memory. */ void priorityqueue_destroy( - PriorityQueue* priorityQueue ///< "this" pointer. + PriorityQueue* priorityQueue ///< "this" pointer. ); #endif