X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=src%2FStack.h;h=b6a3bf474fb5e0ae270e4ef216f6bacef47c779c;hb=eed1b5d2fca21abae2540b500f4a4ed94a809403;hp=c314c28a7ca174f1b61c2b6eae25ad566e13d920;hpb=10b9967a8486514da0d3c534d9403c42d05527f0;p=cgds.git diff --git a/src/Stack.h b/src/Stack.h index c314c28..b6a3bf4 100644 --- a/src/Stack.h +++ b/src/Stack.h @@ -15,115 +15,115 @@ * @brief Stack containing generic data. */ typedef struct Stack { - size_t dataSize; ///< Size in bytes of a stack element. - Vector* array; ///< Internal data structure: resizeable array. + size_t dataSize; ///< Size in bytes of a stack element. + Vector* array; ///< Internal data structure: resizeable array. } Stack; /** * @brief Initialize an empty stack. */ void _stack_init( - Stack* stack, ///< "this" pointer. - size_t dataSize ///< Size in bytes of a stack element. + Stack* stack, ///< "this" pointer. + size_t dataSize ///< Size in bytes of a stack element. ); -/** +/** * @brief Return an allocated and initialized stack. */ Stack* _stack_new( - size_t dataSize ///< Size in bytes of a stack element. + size_t dataSize ///< Size in bytes of a stack element. ); -/** +/** * @brief Return an allocated and initialized stack. * @param type Type of a stack element (int, char*, ...). - * + * * Usage: Stack* stack_new( type) */ #define stack_new(type) \ - _stack_new(sizeof(type)) + _stack_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). */ Stack* stack_copy( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); /** * @brief Check if the stack is empty. */ -Bool stack_empty( - Stack* stack ///< "this" pointer. +bool stack_empty( + Stack* stack ///< "this" pointer. ); /** * @brief Return size of the current stack. */ UInt stack_size( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); /** * @brief Add something on top of the stack. */ void _stack_push( - Stack* stack, ///< "this" pointer. - void* data ///< Data to be added. + Stack* stack, ///< "this" pointer. + void* data ///< Data to be added. ); /** * @brief Add something on top of the stack. * @param stack "this" pointer. * @param data Data to be added. - * + * * Usage: void stack_push(Stack* stack, void data) */ #define stack_push(stack, data) \ { \ - typeof((data)) tmp = data; \ - _stack_push(stack,&tmp); \ + typeof(data) tmp = data; \ + _stack_push(stack, &tmp); \ } /** * @brief Return what is on top of the stack. */ void* _stack_top( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); /** * @brief Return what is on top of the stack. * @param stack "this" pointer. * @param data Data to be assigned. - * + * * Usage: void stack_top(Stack* stack, void data) */ #define stack_top(stack, data) \ { \ - void* pData = _stack_top(stack); \ - data = *((typeof(&data))pData); \ + void* pData = _stack_top(stack); \ + data = *((typeof(&data))pData); \ } /** * @brief Remove the top of the stack. */ void stack_pop( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); /** * @brief Clear the entire stack. */ void stack_clear( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); /** * @brief Destroy the stack: clear it, and free 'stack' pointer. */ void stack_destroy( - Stack* stack ///< "this" pointer. + Stack* stack ///< "this" pointer. ); #endif