X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=src%2FQueue.h;h=22d76dccd5bd22fdbb5b9975de6b8455c2e1b7e4;hb=eed1b5d2fca21abae2540b500f4a4ed94a809403;hp=619ae4addce82ad8b3de5c9f8c1d260bde0ef3c9;hpb=012c97ddf103ecd983df2520f87ca0c31010f9f2;p=cgds.git diff --git a/src/Queue.h b/src/Queue.h index 619ae4a..22d76dc 100644 --- a/src/Queue.h +++ b/src/Queue.h @@ -9,15 +9,15 @@ #include #include "cgds/types.h" #include "cgds/safe_alloc.h" -#include "cgds/Vector.h" +#include "cgds/List.h" /** * @brief Queue containing generic data. * @param dataSize Size in bytes of a queue element. */ typedef struct Queue { - size_t dataSize; ///< Size in bytes of a queue element. - Vector* array; ///< Internal vector representation + size_t dataSize; ///< Size in bytes of a queue element. + List* list; ///< Internal list representation } Queue; /** @@ -26,107 +26,107 @@ typedef struct Queue { * @param dataSize Size in bytes of a queue element. */ void _queue_init( - Queue* queue, ///< "this" pointer. - size_t dataSize ///< Size in bytes of a queue element. + Queue* queue, ///< "this" pointer. + size_t dataSize ///< Size in bytes of a queue element. ); -/** +/** * @brief Return an allocated and initialized queue. */ Queue* _queue_new( - size_t dataSize ///< Size in bytes of a queue element. + size_t dataSize ///< Size in bytes of a queue element. ); -/** +/** * @brief Return an allocated and initialized queue. * @param type Type of a queue element (int, char*, ...). - * + * * Usage: Queue* queue_new( type) */ #define queue_new(type) \ - _queue_new(sizeof(type)) + _queue_new(sizeof(type)) /** - * @brief Copy constructor (works well if items do not have allocated sub-pointers). + * @brief Copy constructor (shallow copy, ok for basic types). */ Queue* queue_copy( - Queue* queue ///< "this" pointer. + Queue* queue ///< "this" pointer. ); /** * @brief Check if the queue is empty. */ -Bool queue_empty( - Queue* queue ///< "this" pointer. +bool queue_empty( + Queue* queue ///< "this" pointer. ); /** * @brief Return size of the current queue. */ UInt queue_size( - Queue* queue ///< "this" pointer. + Queue* queue ///< "this" pointer. ); /** * @brief Add something at the end of the queue. */ void _queue_push( - Queue* queue, ///< "this" pointer. - void* data ///< Data to be pushed. + Queue* queue, ///< "this" pointer. + void* data ///< Data to be pushed. ); /** * @brief Add something at the end of the queue. * @param queue "this" pointer * @param data Data to be pushed. - * + * * Usage: void queue_push(Queue* queue, void data) */ #define queue_push(queue, data) \ { \ - typeof((data)) tmp = data; \ - _queue_push(queue, &tmp); \ + typeof(data) tmp = data; \ + _queue_push(queue, &tmp); \ } /** * @brief Return what is at the beginning of the queue. */ void* _queue_peek( - Queue* queue ///< "this" pointer. + Queue* queue ///< "this" pointer. ); /** * @brief Return what is at the beginning of the queue. * @param queue "this" pointer. * @param data Data to be assigned. - * + * * Usage: void queue_peek(Queue* queue, void data) */ #define queue_peek(queue, data) \ { \ - void* pData = _queue_peek(queue); \ - data = *((typeof(&data))pData); \ + void* pData = _queue_peek(queue); \ + data = *((typeof(&data))pData); \ } /** * @brief Remove the beginning of the queue. */ void queue_pop( - Queue* queue ///< "this" pointer. + Queue* queue ///< "this" pointer. ); /** * @brief Clear the entire queue. */ void queue_clear( - Queue* queue ///< "this" pointer. + Queue* queue ///< "this" pointer. ); /** * @brief Destroy the queue: clear it, and free 'queue' pointer. */ void queue_destroy( - Queue* queue ///< "this" pointer. + Queue* queue ///< "this" pointer. ); #endif