Generic stack
[Base containers]


Detailed Description

A dynamic stack with configurable token size.


Data Structures

struct  _generic_stack_t

Defines

#define gpop(__t, __s)   ((__t)_gpop(__s))
 Pop a token from the stack. (typecast swallowing version).
#define gpeek(__t, __s, __i)   ((__t)_gpeek(__s,__i))
 Peek the __i -th token from the stack. (typecast swallowing version).
#define gstack_is_empty(_s)   (_s->sp==((word_t)-1))
 Predicate.
#define gstack_is_not_empty(_s)   (_s->sp!=((word_t)-1))
 Predicate.

Typedefs

typedef struct
_generic_stack_t
generic_stack_t
 An instance of a generic stack.

Functions

generic_stack_t new_gstack (word_t token_size)
 Create a new stack.
void gstack_init (generic_stack_t, word_t token_size)
 Init a newly allocated buffer.
void gstack_deinit (generic_stack_t, void(*callback)(void *))
 Deinit a stack, calling callback on each token the stack contains.
void gpush (generic_stack_t s, void *w)
 Push the token pointed to by w onto the stack.
void * _gpop (generic_stack_t s)
 Pop a token from the stack.
void * _gpeek (generic_stack_t s, int)
 Peek the i-th token from the stack. (0 is top).
void free_gstack (generic_stack_t s)
 Free a stack.
word_t gstack_size (generic_stack_t s)
 Get the current size of the stack.
void gstack_grow (generic_stack_t s, word_t count)
 Reserve count words on stack.
void gstack_shrink (generic_stack_t s, word_t count)
 Undo a previous reservation.


Define Documentation

#define gpop ( __t,
__s   )     ((__t)_gpop(__s))

Pop a token from the stack. (typecast swallowing version).

#define gpeek ( __t,
__s,
__i   )     ((__t)_gpeek(__s,__i))

Peek the __i -th token from the stack. (typecast swallowing version).

#define gstack_is_empty ( _s   )     (_s->sp==((word_t)-1))

Predicate.

#define gstack_is_not_empty ( _s   )     (_s->sp!=((word_t)-1))

Predicate.


Typedef Documentation

typedef struct _generic_stack_t* generic_stack_t

An instance of a generic stack.


Function Documentation

generic_stack_t new_gstack ( word_t  token_size  ) 

Create a new stack.

void gstack_init ( generic_stack_t  ,
word_t  token_size 
)

Init a newly allocated buffer.

void gstack_deinit ( generic_stack_t  ,
void(*)(void *)  callback 
)

Deinit a stack, calling callback on each token the stack contains.

void gpush ( generic_stack_t  s,
void *  w 
)

Push the token pointed to by w onto the stack.

void* _gpop ( generic_stack_t  s  ) 

Pop a token from the stack.

void* _gpeek ( generic_stack_t  s,
int   
)

Peek the i-th token from the stack. (0 is top).

void free_gstack ( generic_stack_t  s  ) 

Free a stack.

word_t gstack_size ( generic_stack_t  s  ) 

Get the current size of the stack.

void gstack_grow ( generic_stack_t  s,
word_t  count 
)

Reserve count words on stack.

void gstack_shrink ( generic_stack_t  s,
word_t  count 
)

Undo a previous reservation.


Generated on Wed Feb 6 14:46:05 2008 for TinyaML by  doxygen 1.5.3