Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.

LibLapin's logo

LibLapin

Stack





The stack module header is lapin/container/stack.h.
typedef struct s_bunny_stack
{
     const size_t length;
     const void * const * const top;

} t‌_‌b‌u‌n‌n‌y‌_‌s‌t‌a‌c‌k;

Description

     This structure is the main data of the Stack container.

     This type cannot be declared on stack. It must be created by a call to b‌u‌n‌n‌y‌_‌n‌e‌w‌_‌s‌t‌a‌c‌k.

Attributes

  • const size_t length:
         The amount of elements in the Stack container.
  • const void * const * const * top:
         A pointer to a node containing the first element of the Stack container, and the address of its following element if there is one. This attribute is NULL if there is no element inside the Stack.


INDEX

typedef struct s_bunny_stack_node
{
     void *data;
     struct s_bunny_stack_node *next;

} t‌_‌b‌u‌n‌n‌y‌_‌s‌t‌a‌c‌k‌_‌n‌o‌d‌e;

Description

     This structure is the node in which every single data is referenced inside the stack.

Attributes

  • void *data:
         A pointer to a stored data.
  • struct s_bunny_stack_node *next:
         The node following the current one or NULL if there is none.
    This type is an inside type of the Stack module and should not be created by you.


INDEX


Description

     Create an Stack.

Return value

  • The function returns the address of the created Stack or NULL if an error occured.

Error values and logs

On error, $Vb‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:
    Out of memory.


INDEX


Description

     Delete the sent stack. Do not delete elements that was stored.

Parameters


Return value

  • The function returns the amount of element that was stored inside it before being destroyed.

Logs

Logs written by this function are tagged with the "container" label.



INDEX


Description

     Return the amount of elements inside the Stack container.

Parameters


Return value

  • This function returns the amount of elements inside the Stack container.


INDEX


Description

     Return if the sent Stack container is empty.

Parameters


Return value

  • This function returns true if the sent Stack is empty.


INDEX


Description

     Return the element that is on top of the sent Stack.

Parameters


Return value

  • This function returns the top element of the sent Stack or NULL if there is none.


INDEX


Description

     Push at the top of the Stack the sent data.

Parameters


Return value

  • This function return true if the sent data was added inside the stack.

Error values and logs

On error, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:

    Out of memory.


Logs written by this function are tagged with the "container" label.


Additional informations

This macro wraps a call to a real function, which is:

bool _b‌u‌n‌n‌y‌_‌s‌t‌a‌c‌k‌_‌p‌u‌s‌h(t‌_‌b‌u‌n‌n‌y‌_‌s‌t‌a‌c‌k *stack, void *data);




INDEX


Description

     Remove the top element from the sent Stack.

Parameters


Return value

  • This function return the popped value or NULL if there was none.

Error values and logs

On error, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • E_CONTAINER_IS_EMPTY:

    The stack you tried to pop is empty.


Logs written by this function are tagged with the "container" label.


Additional informations

This macro wraps a call to a real function, which is:

void *_b‌u‌n‌n‌y‌_‌s‌t‌a‌c‌k‌_‌p‌o‌p(t‌_‌b‌u‌n‌n‌y‌_‌s‌t‌a‌c‌k *stack);




INDEX