mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
Move other test main()s out of library source files.
Having stated the principle in the previous commit, I should apply it consistently. A source file linked into the Puzzles library of common support code should not also define a main() under ifdef. This commit only goes as far as the _library_ support modules. It would be a much bigger job to do the same for all the actual _puzzles_ that have test main()s or standalone-solver main()s. And it's not necessary, because modifying one of those source files only triggers a rebuild of _one_ puzzle, not absolutely everything. (Not to mention that it's quite likely the puzzle and the test main() will need to be modified in conjunction anyway.) As in the previous commit, this has required exposing a few internal API functions as global, and maybe editing them a bit. In particular, the one-shot internal function that divvy_rectangle() loops on until it succeeds is now exposed as divvy_rectangle_attempt(), which means the test program doesn't have to condition a failure counter into the real function. I've thrown away penrose-vector-test completely, because that didn't look like a test program with any ongoing use at all - it was surely vestigial, while James was getting the vector representation up and running in the first place.
This commit is contained in:
24
tree234.h
24
tree234.h
@ -31,7 +31,11 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
/*
|
||||
* This typedef is opaque outside tree234.c itself.
|
||||
* This typedef is typically opaque outside tree234.c itself. But you
|
||||
* can define TREE234_INTERNALS to get a definition of it and its
|
||||
* subsidiary node structure, as long as you're prepared to commit to
|
||||
* responding to changes in the internals (which probably means you're
|
||||
* tree234.c itself or tree234-test.c).
|
||||
*/
|
||||
typedef struct tree234_Tag tree234;
|
||||
|
||||
@ -39,6 +43,24 @@ typedef int (*cmpfn234)(void *, void *);
|
||||
|
||||
typedef void *(*copyfn234)(void *state, void *element);
|
||||
|
||||
#ifdef TREE234_INTERNALS
|
||||
typedef struct node234_Tag node234;
|
||||
|
||||
struct tree234_Tag {
|
||||
node234 *root;
|
||||
cmpfn234 cmp;
|
||||
};
|
||||
|
||||
struct node234_Tag {
|
||||
node234 *parent;
|
||||
node234 *kids[4];
|
||||
int counts[4];
|
||||
void *elems[3];
|
||||
};
|
||||
|
||||
int height234(tree234 *t);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Create a 2-3-4 tree. If `cmp' is NULL, the tree is unsorted, and
|
||||
* lookups by key will fail: you can only look things up by numeric
|
||||
|
Reference in New Issue
Block a user