data_structures
|
Go to the source code of this file.
Data Structures | |
struct | s_array |
A resizable array. More... | |
Macros | |
#define | ARRAY_INIT_CAPACITY 4 |
The initial capacity of an array. More... | |
Typedefs | |
typedef struct s_array | t_array |
Functions | |
void | array_delete (t_array *array) |
Deletes this array and free all its items and the associated data. More... | |
void * | array_get (const t_array *array, size_t index) |
Returns the item at the specified position in this list. More... | |
void | array_set (t_array *array, size_t index, const void *content) |
Replaces the element at the specified position in this array with a copy of the specified element. More... | |
void | array_append (t_array *array, const void *content) |
Appends a copy the specified element to the end of this array. More... | |
void * | array_pop (t_array *array) |
Removes and returns the element at the end of this array. More... | |
void | array_swap (t_array *array, size_t ind1, size_t ind2) |
Swaps elements at the two specified positions in the array. More... | |
size_t | array_size (const t_array *array) |
Returns the number of elements in this array. More... | |
t_array * | array_new (const t_type *type) |
Initializes a new empty array. More... | |
t_array * | array_zeros (const t_type *type, size_t size) |
Initializes a new array of the specified size, filled with zeros. More... | |
void | array_remove (t_array *array, size_t index) |
Deletes the item at the specified index. More... | |
void | array_insert (t_array *array, size_t index, const void *content) |
Inserts a copy of the specified item at the specified index. More... | |
void | array_insertion_sort (t_array *array) |
Sorts this array using insertion sort. More... | |
void | array_merge_sort (t_array *array) |
Sorts this array using merge sort. More... | |
void | array_quick_sort (t_array *array) |
Sorts this array using quick sort. More... | |
int | array_sorted (const t_array *array) |
Checks if an array is sorted in ascending order. More... | |
t_array * | array_copy (const t_array *array) |
Copies the array and all it contents. More... | |
t_queue * | array_to_queue (const t_array *array) |
Returns a queue that contains copies of the element in this array. More... | |
ssize_t | array_indexof (const t_array *array, const void *val) |
Returns the index at which the specified value is found in the array, or -1 if the value isn't the array. More... | |
#define ARRAY_INIT_CAPACITY 4 |
void array_append | ( | t_array * | array, |
const void * | content | ||
) |
Appends a copy the specified element to the end of this array.
content | The item to be copied |
Definition at line 17 of file array_append.c.
Copies the array and all it contents.
Definition at line 16 of file array_copy.c.
void array_delete | ( | t_array * | array | ) |
Deletes this array and free all its items and the associated data.
Does nothing if the argument is NULL
.
Definition at line 16 of file array_delete.c.
void* array_get | ( | const t_array * | array, |
size_t | index | ||
) |
Returns the item at the specified position in this list.
NULL
if the index is out of range. index | The index (0-based counting) |
EINVAL | Index is out of range |
Definition at line 16 of file array_get.c.
ssize_t array_indexof | ( | const t_array * | array, |
const void * | val | ||
) |
Returns the index at which the specified value is found in the array, or -1
if the value isn't the array.
val | The value |
-1
if the value isn't the array. cmp
function). Definition at line 16 of file array_indexof.c.
void array_insert | ( | t_array * | array, |
size_t | index, | ||
const void * | content | ||
) |
Inserts a copy of the specified item at the specified index.
index | The index at which to insert |
content | The item to be copied |
Definition at line 17 of file array_insert.c.
void array_insertion_sort | ( | t_array * | array | ) |
Sorts this array using insertion sort.
cmp
function). Definition at line 28 of file array_insertion_sort.c.
void array_merge_sort | ( | t_array * | array | ) |
Sorts this array using merge sort.
0
on success, 1
on failure. In case of an error, errno
is set accordingly. cmp
function). Definition at line 73 of file array_merge_sort.c.
Initializes a new empty array.
type | The type of items that this array can hold |
Definition at line 16 of file array_new.c.
void* array_pop | ( | t_array * | array | ) |
Removes and returns the element at the end of this array.
NULL
if the array is empty. Definition at line 17 of file array_pop.c.
void array_quick_sort | ( | t_array * | array | ) |
Sorts this array using quick sort.
cmp
function). Definition at line 50 of file array_quick_sort.c.
void array_remove | ( | t_array * | array, |
size_t | index | ||
) |
Deletes the item at the specified index.
index | The index |
Definition at line 17 of file array_remove.c.
void array_set | ( | t_array * | array, |
size_t | index, | ||
const void * | content | ||
) |
Replaces the element at the specified position in this array with a copy of the specified element.
index | The index (0-based counting) |
content | The item to be copied. |
ENOMEM | Memory allocation error |
EINVAL | Index is out of range |
Definition at line 16 of file array_set.c.
size_t array_size | ( | const t_array * | array | ) |
Returns the number of elements in this array.
Definition at line 16 of file array_size.c.
int array_sorted | ( | const t_array * | array | ) |
Checks if an array is sorted in ascending order.
1
if the array is sorted, 0
if the array is not sorted. cmp
function). Definition at line 16 of file array_sorted.c.
void array_swap | ( | t_array * | array, |
size_t | ind1, | ||
size_t | ind2 | ||
) |
Swaps elements at the two specified positions in the array.
ind1 | The index of the first element |
ind2 | The index of the second element |
Definition at line 16 of file array_swap.c.
Returns a queue that contains copies of the element in this array.
Definition at line 16 of file array_to_queue.c.
Initializes a new array of the specified size, filled with zeros.
type | The type of items that this array can hold |
size | The size |
Definition at line 16 of file array_zeros.c.