cl

0

Описание

C Container Library

Языки

  • C92%
  • Makefile8%

pro100ren4

21 авг 2025, 04:09
README
# CL (CONTAINER LIBRARY)
 
Small C container library
 
## Desctiprion
 
This is small container library contains only 2 data scructures:
- Strechy Buffer;
- Hash map;
 
## Usage examples
 
### Strechy buffer
```c
#include <stdlib.h>
#include "cl.h"
 
int main(int argc, char **argv) {
char *arr = NULL;
 
for (int i = 0; i < 26; ++i) {
arrpush(arr, 'A' + i);
}
 
arrfree(arr);
arr = NULL;
}
```
 
## Hash map
```c
#include <stdlib.h>
#include "cl.h"
 
int main(int argc, char **argv) {
hash_t floats_lookup;
float *floats = NULL;
 
hash_init(&floats_lookup, 50);
for (int i = 0; i < 26; ++i) {
arrpush(arr, i * 2 / 1.5f);
hash_add(&floats_lookup, hash('A' + i), arrcount(arr) - 1);
}
 
float val = floats[hash_lookup(&floats_lookup, hash('A'), 0)];
 
 
 
arrfree(floats);
floats = NULL;
hash_destroy(&floats_lookup);
}
```