Skip to content

Commit

Permalink
sample includes should be better sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
agl-alexglopez committed Nov 22, 2024
1 parent 981e7e9 commit 7842bd7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
24 changes: 12 additions & 12 deletions samples/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <limits.h>
#include <stdbool.h>
#include <stddef.h>
Expand All @@ -30,10 +24,16 @@ Enter 'q' to quit. */
#include <string.h>
#include <time.h>

#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"
Expand Down Expand Up @@ -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}});
Expand Down Expand Up @@ -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. */
Expand Down
11 changes: 5 additions & 6 deletions samples/maze.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <assert.h>
#include <limits.h>
#include <stdbool.h>
Expand All @@ -30,6 +24,11 @@ queue and ordered_map provided by this library.
#include <string.h>
#include <time.h>

#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"
Expand Down
5 changes: 2 additions & 3 deletions samples/words.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ctype.h>
#include <errno.h>
#include <limits.h>
Expand All @@ -22,6 +19,8 @@ Please specify a command as follows:
#include <stdlib.h>
#include <string.h>

#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"
Expand Down

0 comments on commit 7842bd7

Please sign in to comment.