libamxc
1.10.3
C Generic Data Containers
|
Typedefs | |
typedef amxc_llist_t | amxc_lstack_t |
The linked stack structure. More... | |
typedef amxc_llist_it_t | amxc_lstack_it_t |
The linked stack iterator structure. More... | |
typedef amxc_llist_it_delete_t | amxc_lstack_it_delete_t |
Definition of the item delete function. More... | |
Functions | |
AMXC_INLINE int | amxc_lstack_new (amxc_lstack_t **lstack) |
Allocates a linked stack. More... | |
AMXC_INLINE void | amxc_lstack_delete (amxc_lstack_t **lstack, amxc_lstack_it_delete_t func) |
Frees the previously allocated linked stack. More... | |
AMXC_INLINE int | amxc_lstack_init (amxc_lstack_t *const lstack) |
Initializes a linked stack. More... | |
AMXC_INLINE void | amxc_lstack_clean (amxc_lstack_t *const lstack, amxc_lstack_it_delete_t func) |
Removes all items from the linked stack. More... | |
AMXC_INLINE int | amxc_lstack_push (amxc_lstack_t *const lstack, amxc_lstack_it_t *const it) |
Adds an item to the linked stack. More... | |
AMXC_INLINE amxc_lstack_it_t * | amxc_lstack_pop (amxc_lstack_t *const lstack) |
Removes the last added item from the stack. More... | |
AMXC_INLINE amxc_lstack_it_t * | amxc_lstack_peek (amxc_lstack_t *const lstack) |
Peeks the top of the stack, without removing. More... | |
AMXC_INLINE size_t | amxc_lstack_size (const amxc_lstack_t *const lstack) |
Calculates the size of the stack, expressed in number of items. More... | |
AMXC_INLINE bool | amxc_lstack_is_empty (const amxc_lstack_t *const lstack) |
Checks if the linked stack is empty. More... | |
AMXC_INLINE int | amxc_lstack_it_init (amxc_lstack_it_t *const it) |
Initializes a linked stack iterator. More... | |
Definition of the item delete function.
A pointer to a delete function is used in the following functions amxc_lstack_delete, amxc_lstack_clean
Definition at line 99 of file amxc_lstack.h.
typedef amxc_llist_it_t amxc_lstack_it_t |
The linked stack iterator structure.
Definition at line 89 of file amxc_lstack.h.
typedef amxc_llist_t amxc_lstack_t |
The linked stack structure.
Definition at line 82 of file amxc_lstack.h.
AMXC_INLINE void amxc_lstack_clean | ( | amxc_lstack_t *const | lstack, |
amxc_lstack_it_delete_t | func | ||
) |
Removes all items from the linked stack.
Removes all items from the linked stack, if a delete function is provided, it is called for each item after it was removed from the stack.
lstack | a pointer to the linked stack structure |
func | a pointer to a function that is called to free each item in the linked stack |
Definition at line 190 of file amxc_lstack.h.
AMXC_INLINE void amxc_lstack_delete | ( | amxc_lstack_t ** | lstack, |
amxc_lstack_it_delete_t | func | ||
) |
Frees the previously allocated linked stack.
Removes all items from the linked stack, if a delete function is provided, it is called for each item after it was removed from the stack.
Frees the allocated memory and sets the pointer to NULL.
lstack | a pointer to the location where the pointer to the linked stack is stored |
func | a pointer to a function that is called to free each item in the linked stack |
Definition at line 146 of file amxc_lstack.h.
AMXC_INLINE int amxc_lstack_init | ( | amxc_lstack_t *const | lstack | ) |
Initializes a linked stack.
Initializes the linked stack structure. All pointers are reset to NULL. This function is typically called for linked stacks that are on the stack. Allocating and initializing a linked stack on the heap can be done using amxc_lstack_new
lstack | a pointer to the linked stack structure. |
Definition at line 172 of file amxc_lstack.h.
AMXC_INLINE bool amxc_lstack_is_empty | ( | const amxc_lstack_t *const | lstack | ) |
Checks if the linked stack is empty.
lstack | a pointer to the linked stack structure |
Definition at line 275 of file amxc_lstack.h.
AMXC_INLINE int amxc_lstack_it_init | ( | amxc_lstack_it_t *const | it | ) |
Initializes a linked stack iterator.
Initializes the linked stack iterator structure. All pointers are reset to NULL.
it | a pointer to the linked stack iterator structure. |
Definition at line 299 of file amxc_lstack.h.
AMXC_INLINE int amxc_lstack_new | ( | amxc_lstack_t ** | lstack | ) |
Allocates a linked stack.
Allocates and initializes memory to store a linked stack. This function allocates memory from the heap, if a linked stack is on the stack, it can be initialized using function amxc_lstack_init
lstack | a pointer to the location where the pointer to the new linked stack can be stored |
Definition at line 122 of file amxc_lstack.h.
AMXC_INLINE amxc_lstack_it_t* amxc_lstack_peek | ( | amxc_lstack_t *const | lstack | ) |
Peeks the top of the stack, without removing.
lstack | a pointer to the linked stack structure |
Definition at line 243 of file amxc_lstack.h.
AMXC_INLINE amxc_lstack_it_t* amxc_lstack_pop | ( | amxc_lstack_t *const | lstack | ) |
Removes the last added item from the stack.
lstack | a pointer to the linked stack structure |
Definition at line 228 of file amxc_lstack.h.
AMXC_INLINE int amxc_lstack_push | ( | amxc_lstack_t *const | lstack, |
amxc_lstack_it_t *const | it | ||
) |
Adds an item to the linked stack.
If the item is already in a stack, it is removed from that stack.
lstack | a pointer to the linked stack structure |
it | a pointer to the linked stack item iterator |
Definition at line 213 of file amxc_lstack.h.
AMXC_INLINE size_t amxc_lstack_size | ( | const amxc_lstack_t *const | lstack | ) |
Calculates the size of the stack, expressed in number of items.
lstack | a pointer to the linked stack structure |
Definition at line 259 of file amxc_lstack.h.