https://github.com/amwolff/libmaps
Associative maps built on top of the AVL tree for C programming language
https://github.com/amwolff/libmaps
associative-map associative-memory associative-storage c library maps
Last synced: 2 months ago
JSON representation
Associative maps built on top of the AVL tree for C programming language
- Host: GitHub
- URL: https://github.com/amwolff/libmaps
- Owner: amwolff
- License: mit
- Created: 2018-05-09T22:48:02.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-17T21:47:37.000Z (over 6 years ago)
- Last Synced: 2025-02-01T11:32:31.923Z (4 months ago)
- Topics: associative-map, associative-memory, associative-storage, c, library, maps
- Language: C
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libmaps
Associative maps built on top of the AVL tree for C programming language.This super-simple library has no unit tests (I would discourage from using it in serious use) and supports only int-int maps (see example). This could be changed to any type (preferably void pointers), but for now I'm leaving this the way it is.
And it should be blazingly fast.
## Example
```
#include
#include
#include "libmaps/libmaps.h"int main() {
map numbers = make_map_int_int();
if (numbers == NULL) {
return 1;
}int *check;
check = insert(numbers, 1, 4370483);
if (check == NULL) {
return 1;
}
check = insert(numbers, 2, 5501881);
if (check == NULL) {
return 1;
}
check = insert(numbers, 3, 7824519);
if (check == NULL) {
return 1;
}int *number = lookup(numbers, 3);
if (number == NULL) {
return 1;
}
printf("(29) %d: %d\n", 3, *number);delete(numbers, 2);
number = lookup(numbers, 2);
if (number == NULL) {
printf("(35) Number of ID 2 not found!\n");
}return 0;
}
```Output:
```
(29) 3: 7824519
(35) Number of ID 2 not found!
```