diff --git a/samples/graph.c b/samples/graph.c index 5117aa4..0ea7de0 100644 --- a/samples/graph.c +++ b/samples/graph.c @@ -15,12 +15,6 @@ AB A->B CtoD Enter 'q' to quit. */ -#include "realtime_ordered_map.h" -#define FLAT_HASH_MAP_USING_NAMESPACE_CCC -#define FLAT_DOUBLE_ENDED_QUEUE_USING_NAMESPACE_CCC -#define PRIORITY_QUEUE_USING_NAMESPACE_CCC -#define TRAITS_USING_NAMESPACE_CCC - #include #include #include @@ -30,10 +24,16 @@ Enter 'q' to quit. */ #include #include +#define FLAT_HASH_MAP_USING_NAMESPACE_CCC +#define FLAT_DOUBLE_ENDED_QUEUE_USING_NAMESPACE_CCC +#define REALTIME_ORDERED_MAP_USING_NAMESPACE_CCC +#define PRIORITY_QUEUE_USING_NAMESPACE_CCC +#define TRAITS_USING_NAMESPACE_CCC #include "alloc.h" #include "ccc/flat_double_ended_queue.h" #include "ccc/flat_hash_map.h" #include "ccc/priority_queue.h" +#include "ccc/realtime_ordered_map.h" #include "ccc/traits.h" #include "ccc/types.h" #include "cli.h" @@ -457,7 +457,7 @@ has_built_edge(struct graph *const graph, struct vertex *const src, elem, std_alloc, hash_parent_cells, eq_parent_cells, NULL); prog_assert(res == CCC_OK); flat_double_ended_queue bfs - = ccc_fdeq_init((struct point *)NULL, std_alloc, NULL, 0); + = fdeq_init((struct point *)NULL, std_alloc, NULL, 0); ccc_entry *e = fhm_insert_or_assign_w( &parent_map, src->pos, (struct path_backtrack_cell){.parent = {-1, -1}}); @@ -736,11 +736,11 @@ dijkstra_shortest_path(struct graph *const graph, struct path_request const pr) prog_assert(bump_arena.vertices); /* The realtime ordered map and priority queue both have pointer stability and therefore can be safely composed together in the same struct. */ - ccc_realtime_ordered_map path_map = ccc_rom_init( - path_map, struct dijkstra_vertex, path_elem, cur_name, - dijkstra_vertex_arena_alloc, cmp_prev_vertices, &bump_arena); - ccc_priority_queue costs_pq = ccc_pq_init( - struct dijkstra_vertex, pq_elem, CCC_LES, NULL, cmp_pq_costs, NULL); + realtime_ordered_map path_map + = rom_init(path_map, struct dijkstra_vertex, path_elem, cur_name, + dijkstra_vertex_arena_alloc, cmp_prev_vertices, &bump_arena); + priority_queue costs_pq = pq_init(struct dijkstra_vertex, pq_elem, CCC_LES, + NULL, cmp_pq_costs, NULL); /* The lifetime of elements in the map and priority queue are identical. We don't have to worry about removing one before the other. All stay in the map and priority queue for the entirety of the algorithm. */ diff --git a/samples/maze.c b/samples/maze.c index 78b6db3..f351ae0 100644 --- a/samples/maze.c +++ b/samples/maze.c @@ -15,12 +15,6 @@ queue and ordered_map provided by this library. -s=N The speed flag lets you specify the speed of the animation 0-7. Example: ./build/[debug/]bin/maze -c=111 -r=33 -s=4 */ -#define TRAITS_USING_NAMESPACE_CCC -#define TYPES_USING_NAMESPACE_CCC -#define BUFFER_USING_NAMESPACE_CCC -#define PRIORITY_QUEUE_USING_NAMESPACE_CCC -#define ORDERED_MAP_USING_NAMESPACE_CCC - #include #include #include @@ -30,6 +24,11 @@ queue and ordered_map provided by this library. #include #include +#define TRAITS_USING_NAMESPACE_CCC +#define TYPES_USING_NAMESPACE_CCC +#define BUFFER_USING_NAMESPACE_CCC +#define PRIORITY_QUEUE_USING_NAMESPACE_CCC +#define ORDERED_MAP_USING_NAMESPACE_CCC #include "ccc/ordered_map.h" #include "ccc/priority_queue.h" #include "ccc/traits.h" diff --git a/samples/words.c b/samples/words.c index ebadcb0..c4d43b3 100644 --- a/samples/words.c +++ b/samples/words.c @@ -10,9 +10,6 @@ Please specify a command as follows: -top=N reports the top N words by frequency. -last=N reports the last N words by frequency -find=[WORD] reports the count of the specified word. */ -#define TRAITS_USING_NAMESPACE_CCC -#define FLAT_ORDERED_MAP_USING_NAMESPACE_CCC - #include #include #include @@ -22,6 +19,8 @@ Please specify a command as follows: #include #include +#define TRAITS_USING_NAMESPACE_CCC +#define FLAT_ORDERED_MAP_USING_NAMESPACE_CCC #include "alloc.h" #include "ccc/flat_ordered_map.h" #include "ccc/flat_priority_queue.h"