43 lines
822 B
C
43 lines
822 B
C
/* This software is licensed by the MIT License, see LICENSE file */
|
|
/* Copyright © 2022 Gregory Lirent */
|
|
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include "../include/set.h"
|
|
|
|
typedef vtype_set vset_t;
|
|
|
|
int print_value(const void* value, vtype type, void* data) {
|
|
const char *n = data;
|
|
vtype_int32 *v = (void*)value;
|
|
|
|
assert(type == VTYPE_INT32);
|
|
|
|
printf("%s %d\n", n, *v);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
vset_t set;
|
|
int a, b;
|
|
|
|
vset_init(&set, VTYPE_INT32);
|
|
|
|
for (size_t i = 0; i < 28; ++i) {
|
|
vset_push(&set, i);
|
|
}
|
|
|
|
a = 13;
|
|
b = 18;
|
|
|
|
vset_get(&set, a, "Get value:", print_value);
|
|
vset_pop(&set, b, "Pop value:", print_value);
|
|
|
|
vset_foreach(&set, "Foreach loop:", print_value);
|
|
|
|
vset_free(&set);
|
|
}
|