Refactor map, add attaching functional
This commit is contained in:
+10
-6
@@ -4,7 +4,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "../include/extra/map.h"
|
||||
#include "../include/map.h"
|
||||
|
||||
typedef vtype_map map_t;
|
||||
|
||||
@@ -34,20 +34,24 @@ int main(int argc, char** argv) {
|
||||
|
||||
map_t map;
|
||||
vtype_float fl = 0.0;
|
||||
int a, b;
|
||||
|
||||
map_init(&map, VTYPE_INT32);
|
||||
|
||||
for (size_t i = 0; i < 28; ++i) {
|
||||
for (vtype_int32 i = 0; i < 28; ++i) {
|
||||
if (i%2) {
|
||||
map_update(&map, i, (vtype_int32)i);
|
||||
map_update(&map, i, i);
|
||||
} else {
|
||||
map_update(&map, i, (vtype_float)fl);
|
||||
map_update(&map, i, fl);
|
||||
fl += 0.05;
|
||||
}
|
||||
}
|
||||
|
||||
map_get(&map, 13, "Get value:", print_value);
|
||||
map_pop(&map, 18, "Pop value:", print_value);
|
||||
a = 13;
|
||||
b = 18;
|
||||
|
||||
map_get(&map, a, "Get value:", print_value);
|
||||
map_pop(&map, b, "Pop value:", print_value);
|
||||
|
||||
map_foreach(&map, "Foreach loop:", print_value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user