O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
push_pop.c File Reference

Add and remove elements from dynamic arrays. More...

#include "private.h"
#include "o2s/array.h"
#include <iso646.h>
#include <string.h>

Go to the source code of this file.

Functions

bool array_push_back_n (array_t *self, const void *elements, size_t count)
 Adds count elements at the end of the array.
bool array_push_back (array_t *self, const void *element)
 Adds one element at the end of the array.
bool array_pop_back_n (array_t *self, void *destination, size_t count)
 Moves to destination the n last elements of the array.
bool array_pop_back (array_t *self, void *destination)
 Moves to destination the last element of the array.
bool array_pop_front_n (array_t *self, void *destination, size_t count)
 Moves to destination the count first elements of self.
bool array_pop_front (array_t *self, void *destination)
 Moves to destination the first element of self.

Detailed Description

Add and remove elements from dynamic arrays.

Author
Hugo FOLCHER
Antoine GAGNIERE

Definition in file push_pop.c.

Function Documentation

◆ array_pop_back()

bool array_pop_back ( array_t * self,
void * destination )

Moves to destination the last element of the array.

Returns
false if the array is empty.

Definition at line 68 of file push_pop.c.

◆ array_pop_back_n()

bool array_pop_back_n ( array_t * self,
void * destination,
size_t count )

Moves to destination the n last elements of the array.

Destination can be NULL to just discard the elements.

Returns
false if not enough element in the array.

Definition at line 53 of file push_pop.c.

◆ array_pop_front()

bool array_pop_front ( array_t * self,
void * destination )

Moves to destination the first element of self.

Returns
false if the array is empty

Definition at line 93 of file push_pop.c.

◆ array_pop_front_n()

bool array_pop_front_n ( array_t * self,
void * destination,
size_t count )

Moves to destination the count first elements of self.

Returns
false if there are not enough elements in the array

Definition at line 77 of file push_pop.c.

◆ array_push_back()

bool array_push_back ( array_t * self,
const void * element )

Adds one element at the end of the array.

Returns
false if allocation failed.

Definition at line 43 of file push_pop.c.

◆ array_push_back_n()

bool array_push_back_n ( array_t * self,
const void * elements,
size_t count )

Adds count elements at the end of the array.

Returns
false if allocation failed.

Definition at line 28 of file push_pop.c.