<commit_before># vec
A type-safe dynamic array implementation for C. 


## Installation 
The [vec.c](src/vec.c?raw=1) and [vec.h](src/vec.h?raw=1) files can be dropped
into an existing C project and compiled along with it.


## Usage
Before using a vector it should first be initialised using the `vec_init()`
function.
```c
vec_int_t v;
vec_init(&v);
vec_push(&v, 123);
vec_push(&v, 456);
```

To access the elements of the vector directly the vector's `members` field can
be used.
```c
printf("%d\n", v.members[1]); /* Prints the value at index 1 */
```

The current length of the vector is stored in the `length` field of the vector
```c
printf("%d\n", v.length); /* Prints the length of the vector */
```

When you are done with the vector the `vec_deinit()` function should be called
on it. This will free any memory the vector allocated during use.
```c
vec_deinit(&v);
```


## Vector Types
To define a new vector type the `vec_t()` macro should be used:
```c
/* Creates the type uint_vec_t for storing unsigned ints */
typedef vec_t(unsigned int) uint_vec_t;
```

vec.h provides the following predefined vector types:

Contained Type  | Type name
----------------|----------------------------------
void*           | vec_void_t
char*           | vec_str_t
int             | vec_int_t
char            | vec_char_t
float           | vec_float_t
double          | vec_double_t


## Functions
All vector functions are macro functions. The parameter `v` in each function
should be a pointer to the vec struct which the operation is to be performed
on.

### vec\_t(T)
Creates a vec struct for containing values of type `T`.
```c
/* Typedefs the struct `fp_vec_t` as a container for type FILE* */
typedef vec_t(FILE*) fp_vec_t;
```

### vec\_init(v)
Initialises the vector, this must be called before the vector can be used. 

### vec\_deinit(v)
Deinitialises the vector, freeing the memory the vector allocated during use;<commit_msg>Renamed section Vector Types -> Types in README.md<commit_after># vec
A type-safe dynamic array implementation for C. 


## Installation 
The [vec.c](src/vec.c?raw=1) and [vec.h](src/vec.h?raw=1) files can be dropped
into an existing C project and compiled along with it.


## Usage
Before using a vector it should first be initialised using the `vec_init()`
function.
```c
vec_int_t v;
vec_init(&v);
vec_push(&v, 123);
vec_push(&v, 456);
```

To access the elements of the vector directly the vector's `members` field can
be used.
```c
printf("%d\n", v.members[1]); /* Prints the value at index 1 */
```

The current length of the vector is stored in the `length` field of the vector
```c
printf("%d\n", v.length); /* Prints the length of the vector */
```

When you are done with the vector the `vec_deinit()` function should be called
on it. This will free any memory the vector allocated during use.
```c
vec_deinit(&v);
```


## Types
vec.h provides the following predefined vector types:

Contained Type  | Type name
----------------|----------------------------------
void*           | vec_void_t
char*           | vec_str_t
int             | vec_int_t
char            | vec_char_t
float           | vec_float_t
double          | vec_double_t

To define a new vector type the `vec_t()` macro should be used:
```c
/* Creates the type uint_vec_t for storing unsigned ints */
typedef vec_t(unsigned int) uint_vec_t;
```


## Functions
All vector functions are macro functions. The parameter `v` in each function
should be a pointer to the vec struct which the operation is to be performed
on.

### vec\_t(T)
Creates a vec struct for containing values of type `T`.
```c
/* Typedefs the struct `fp_vec_t` as a container for type FILE* */
typedef vec_t(FILE*) fp_vec_t;
```

### vec\_init(v)
Initialises the vector, this must be called before the vector can be used. 

### vec\_deinit(v)
Deinitialises the vector, freeing the memory the vector allocated during use;
{'fraction_non_alphanumeric': 0.1273705791901589, 'fraction_numerical': 0.005125576627370579, 'mean_word_length': 3.312707182320442, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2509768', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1159, 'n_words': 514}