Datum is a small library implemented from scratch in plain C99 to port common data structures and algorithms to the C programming language. Right now it provides the following features:
- Support for dynamic array, associative maps arbitrary large integers and UTF-8 strings;
- Support for generic data types;
- Efficient sorting algorithm;
- Functional-style operations (map, filter, reduce);
- Partial support to UTF-8;
- Common arithmetical operations for the
BigInttype.
Datum is built to be easily integrable with existing codebase. To start using it, you just have to copy the relevant header and source files into your project directory.
Below you can find a sample usage:
#include <stdio.h>
#include "vector.h"
int main(void) {
// Create a vector of integers
vector_t *vec = vector_new(5, sizeof(int)).value.vector;
// Push some elements
int nums[] = {5, 4, 1, 2, 3};
for (int idx = 0; idx < 5; idx++) {
vector_push(vec, &nums[idx]);
}
for (int idx = 0; idx < 2; idx++) {
printf("%d ", *(int *)vector_get(vec, idx).value.element);
}
putchar('\n');
// Remove vector from memory
vector_destroy(vec);
return 0;
If you wish to learn more about this library, you can check out the documentation at the following link.