projects
/
cgds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement HashTable + fix some extra blank spaces, remove Bool type (using bool ...
[cgds.git]
/
src
/
Stack.h
diff --git
a/src/Stack.h
b/src/Stack.h
index
d246107
..
24ad176
100644
(file)
--- a/
src/Stack.h
+++ b/
src/Stack.h
@@
-9,22
+9,14
@@
#include <string.h>
#include "cgds/types.h"
#include "cgds/safe_alloc.h"
#include <string.h>
#include "cgds/types.h"
#include "cgds/safe_alloc.h"
-
-/**
- * @brief Generic internal stack cell.
- */
-typedef struct StackCell {
- void* data; ///< Generic data contained in the cell.
- struct StackCell* previous; ///< Previous cell in the internal single-linked list.
-} StackCell;
+#include "cgds/Vector.h"
/**
* @brief Stack containing generic data.
*/
typedef struct Stack {
/**
* @brief Stack containing generic data.
*/
typedef struct Stack {
- UInt size; ///< Count elements in the stack.
size_t dataSize; ///< Size in bytes of a stack element.
size_t dataSize; ///< Size in bytes of a stack element.
-
StackCell* top; ///< Last added element, on top of the stack
.
+
Vector* array; ///< Internal data structure: resizeable array
.
} Stack;
/**
} Stack;
/**
@@
-35,24
+27,24
@@
void _stack_init(
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.
*/
Stack* _stack_new(
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.
);
-/**
+/**
* @brief Return an allocated and initialized stack.
* @param type Type of a stack element (int, char*, ...).
* @brief Return an allocated and initialized stack.
* @param type Type of a stack element (int, char*, ...).
- *
+ *
* Usage: Stack* stack_new(<Type> type)
*/
#define stack_new(type) \
_stack_new(sizeof(type))
/**
* Usage: Stack* stack_new(<Type> type)
*/
#define stack_new(type) \
_stack_new(sizeof(type))
/**
- * @brief Copy constructor (
works well if items do not have allocated sub-pointer
s).
+ * @brief Copy constructor (
shallow copy, ok for basic type
s).
*/
Stack* stack_copy(
Stack* stack ///< "this" pointer.
*/
Stack* stack_copy(
Stack* stack ///< "this" pointer.
@@
-61,7
+53,7
@@
Stack* stack_copy(
/**
* @brief Check if the stack is empty.
*/
/**
* @brief Check if the stack is empty.
*/
-
B
ool stack_empty(
+
b
ool stack_empty(
Stack* stack ///< "this" pointer.
);
Stack* stack ///< "this" pointer.
);
@@
-84,7
+76,7
@@
void _stack_push(
* @brief Add something on top of the stack.
* @param stack "this" pointer.
* @param 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) \
* Usage: void stack_push(Stack* stack, void data)
*/
#define stack_push(stack, data) \
@@
-104,7
+96,7
@@
void* _stack_top(
* @brief Return what is on top of the stack.
* @param stack "this" pointer.
* @param data Data to be assigned.
* @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) \
* Usage: void stack_top(Stack* stack, void data)
*/
#define stack_top(stack, data) \