Functions
tStack

A basic stack of integers with a fixed capacity of 128, used by tPoly to keep track of MIDI notes. More...

Functions

void tStack_init (tStack *const stack, LEAF *const leaf)
 Initialize a tStack to the default mempool of a LEAF instance. More...
 
void tStack_initToPool (tStack *const stack, tMempool *const pool)
 Initialize a tStack to a specified mempool. More...
 
void tStack_free (tStack *const stack)
 Free a tStack from its mempool. More...
 
void tStack_setCapacity (tStack *const stack, uint16_t cap)
 Set the capacity of the stack. More...
 
int tStack_addIfNotAlreadyThere (tStack *const stack, uint16_t item)
 Add a value to the stack only if that value is not already in the stack. More...
 
void tStack_add (tStack *const stack, uint16_t item)
 Add a value to the stack. More...
 
int tStack_remove (tStack *const stack, uint16_t item)
 Remove a single instance of a value from the stack. More...
 
void tStack_clear (tStack *const stack)
 Clear the stack. More...
 
int tStack_first (tStack *const stack)
 Get the first value in the stack. More...
 
int tStack_getSize (tStack *const stack)
 Get the current size of the stack. More...
 
int tStack_contains (tStack *const stack, uint16_t item)
 Check if the stack contains a value, and if it does, get the index of that value. More...
 
int tStack_next (tStack *const stack)
 Get the next value in the stack, starting from the earliest added values. More...
 
int tStack_get (tStack *const stack, int index)
 Get the value at a given index of the stack. More...
 

Detailed Description

A basic stack of integers with a fixed capacity of 128, used by tPoly to keep track of MIDI notes.

Function Documentation

◆ tStack_init()

void tStack_init ( tStack *const  stack,
LEAF *const  leaf 
)

Initialize a tStack to the default mempool of a LEAF instance.

Parameters
stackA pointer to the tStack to initialize.
leafA pointer to the leaf instance.

◆ tStack_initToPool()

void tStack_initToPool ( tStack *const  stack,
tMempool *const  mempool 
)

Initialize a tStack to a specified mempool.

Parameters
stackA pointer to the tStack to initialize.
mempoolA pointer to the tMempool to use.

◆ tStack_free()

void tStack_free ( tStack *const  stack)

Free a tStack from its mempool.

Parameters
stackA pointer to the tStack to free.

◆ tStack_setCapacity()

void tStack_setCapacity ( tStack *const  stack,
uint16_t  cap 
)

Set the capacity of the stack.

Parameters
stackA pointer to the relevant tStack.
capThe new capacity.

◆ tStack_addIfNotAlreadyThere()

int tStack_addIfNotAlreadyThere ( tStack *const  stack,
uint16_t  item 
)

Add a value to the stack only if that value is not already in the stack.

Parameters
stackA pointer to the relevant tStack.
itemThe value to be added.

◆ tStack_add()

void tStack_add ( tStack *const  stack,
uint16_t  item 
)

Add a value to the stack.

Parameters
stackA pointer to the relevant tStack.
itemThe value to be added.

◆ tStack_remove()

int tStack_remove ( tStack *const  stack,
uint16_t  item 
)

Remove a single instance of a value from the stack.

Parameters
stackA pointer to the relevant tStack.
itemThe value to be removed.

◆ tStack_clear()

void tStack_clear ( tStack *const  stack)

Clear the stack.

Parameters
stackA pointer to the relevant tStack.

◆ tStack_first()

int tStack_first ( tStack *const  stack)

Get the first value in the stack.

Parameters
stackA pointer to the relevant tStack.
Returns
The first value in the stack.

◆ tStack_getSize()

int tStack_getSize ( tStack *const  stack)

Get the current size of the stack.

Parameters
stackA pointer to the relevant tStack.
Returns
The current size of the stack.

◆ tStack_contains()

int tStack_contains ( tStack *const  stack,
uint16_t  item 
)

Check if the stack contains a value, and if it does, get the index of that value.

Parameters
stackA pointer to the relevant tStack.
itemThe value to check against the stack.
Returns
The index of the value or -1 if the stack does not contain the value.

◆ tStack_next()

int tStack_next ( tStack *const  stack)

Get the next value in the stack, starting from the earliest added values.

Parameters
stackA pointer to the relevant tStack.
Returns
The next value in the stack or -1 if there are no values in the stack.

◆ tStack_get()

int tStack_get ( tStack *const  stack,
int  index 
)

Get the value at a given index of the stack.

Parameters
stackA pointer to the relevant tStack.
indexThe index of the stack from which to get a value.
Returns
The value at the given index.