Dynarr 0.0.1
C dynamic array
Loading...
Searching...
No Matches
dynarr.h File Reference

Describes dynarr public interface. More...

#include <stdbool.h>
#include <stddef.h>
#include <sys/types.h>
#include "vector.h"
Include dependency graph for dynarr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dynarr_opts_t
 Dynarr creating options. More...
 

Macros

#define DYNARR_DEFAULT_ARGS
 
#define dynarr_create(...)
 Dynarr constructor.
 

Enumerations

enum  dynarr_status_t {
  DYNARR_SUCCESS = VECTOR_SUCCESS , DYNARR_ALLOC_ERROR = VECTOR_ALLOC_ERROR , DYNARR_GROW_ERROR = VECTOR_STATUS_LAST , DYNARR_SHRINK_ERROR ,
  DYNARR_STATUS_LAST
}
 Represents operation error codes. More...
 

Functions

dynarr_t * dynarr_create_ (const dynarr_opts_t *const opts)
 Constructor of the dynamic array.
 
void dynarr_destroy (dynarr_t *const dynarr)
 Deallocates a dynamic array.
 
dynarr_t * dynarr_clone (const dynarr_t *const dynarr)
 Duplicate a dynarr.
 
void * dynarr_get_ext_header (const dynarr_t *const dynarr)
 Retrieve a location of extended header.
 
size_t dynarr_size (const dynarr_t *const dynarr)
 Access size property of a dynarr.
 
size_t dynarr_initial_capacity (const dynarr_t *const dynarr)
 Access initial capacity property.
 
size_t dynarr_capacity (const dynarr_t *const dynarr)
 Access current capacity of the dynarr.
 
void * dynarr_binary_find (const dynarr_t *const dynarr, const void *const value, const compare_t cmp, void *const param)
 Binary search for the element with matching value.
 
ssize_t dynarr_binary_find_index (const dynarr_t *const dynarr, const void *const value, const compare_t cmp, void *const param)
 Binary search for the element with matching value.
 
void dynarr_clear (dynarr_t *const dynarr)
 Clean (reset) contents of the dynarr.
 
void * dynarr_get (const dynarr_t *const dynarr, const size_t index)
 Returns pointer for the element at index.
 
void dynarr_set (dynarr_t *const dynarr, const size_t index, const void *value)
 Sets element at given index to a value.
 
void dynarr_set_zero (dynarr_t *const dynarr, const size_t index)
 Sets element at given index to a zero value.
 
void * dynarr_first (const dynarr_t *const dynarr)
 Access first element of a dynarr.
 
void * dynarr_last (const dynarr_t *const dynarr)
 Access last element if a dynarr.
 
dynarr_status_t dynarr_append (dynarr_t **const dynarr, const void *const value)
 Appends an element to the tail of a dynarr.
 
dynarr_status_t dynarr_prepend (dynarr_t **const dynarr, const void *const value)
 Prepends an element to the head of a dynarr.
 
dynarr_status_t dynarr_pop_back (dynarr_t **const dynarr)
 Removes an element from the tail of a dynarr.
 
dynarr_status_t dynarr_pop_front (dynarr_t **const dynarr)
 Removes an element from the head of a dynarr.
 
dynarr_status_t dynarr_insert (dynarr_t **const dynarr, const size_t index, const void *value)
 Inserts new element into a dynarr.
 
dynarr_status_t dynarr_remove (dynarr_t **const dynarr, const size_t index)
 Removes an element from a dynarr.
 
dynarr_status_t dynarr_remove_range (dynarr_t **const dynarr, const size_t index, const size_t amount)
 Removes range of elements from a dynarr.
 
dynarr_status_t dynarr_remove_if (dynarr_t **const dynarr, const predicate_t predicate, const size_t limit, void *const param)
 Removes limit elements that match predicate.
 
dynarr_t * dynarr_binary_merge (const dynarr_t *const first, const dynarr_t *const second, const compare_t cmp, void *const param)
 Non-destructive merge of two sorted dynarrs.
 
dynarr_status_t dynarr_spread_insert (dynarr_t **const dynarr, const size_t index, const size_t amount, const void *const value)
 Insert single value as an element range.
 
size_t dynarr_binary_find_insert_place (const dynarr_t *const dynarr, const void *const value, const compare_t cmp, void *param)
 Binary search for binary insert support.
 
dynarr_status_t dynarr_binary_insert (dynarr_t **const dynarr, const void *const value, const compare_t cmp, void *const param, size_t *const index)
 Binary insert.
 
dynarr_status_t dynarr_binary_insert_uniq (dynarr_t **const dynarr, const void *const value, const compare_t cmp, void *const param, size_t *const index)
 Binary unique insert.
 
dynarr_status_t dynarr_binary_reserve (dynarr_t **const dynarr, const void *const value, const compare_t cmp, void *const param, size_t *const index)
 Reserve space for an element in sorted dynarr.
 
int dynarr_foreach (const dynarr_t *const dynarr, const foreach_t func, void *const param)
 
int dynarr_aggregate (const dynarr_t *const dynarr, const aggregate_t func, void *const acc, void *const param)
 
int dynarr_transform (dynarr_t *const dynarr, const transform_t func, void *const param)
 

Detailed Description

Describes dynarr public interface.

Author
Evgeni Semenov

Definition in file dynarr.h.

Macro Definition Documentation

◆ DYNARR_DEFAULT_ARGS

#define DYNARR_DEFAULT_ARGS
Value:
.shrink_threshold = 0.25f, \
.grow_threshold = 0.75f, \
.grow_factor = 1.5f
#define VECTOR_DEFAULT_ARGS

Represents dynarrs default create values.

Definition at line 59 of file dynarr.h.

Enumeration Type Documentation

◆ dynarr_status_t

Represents operation error codes.

Can be extended further.

See also
vector_status_t
Enumerator
DYNARR_SUCCESS 

Success status inherited from VECTOR_SUCCESS.

DYNARR_ALLOC_ERROR 

Success status inherited from VECTOR_ALLOC_ERROR.

DYNARR_GROW_ERROR 

Allocation error on grow.

Where dynarr specific status codes begin at.

DYNARR_SHRINK_ERROR 

Success status inherited from VECTOR_ALLOC_ERROR.

DYNARR_STATUS_LAST 

Total number of valid dynarr status codes.

Extension point for derived enum codes

Definition at line 42 of file dynarr.h.