aboutsummaryrefslogtreecommitdiff
path: root/puzzles.h
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2023-04-20 15:32:10 +0100
committerSimon Tatham <anakin@pobox.com>2023-04-20 18:39:35 +0100
commit14e1e05510ac02a5502823bafe46d98c6fab3e5c (patch)
treed7e99ac9bb574bc62a324cf3bb435b485c1113b3 /puzzles.h
parent088fdeee38599b1711ba8766d36c652f1355e36e (diff)
downloadpuzzles-14e1e05510ac02a5502823bafe46d98c6fab3e5c.zip
puzzles-14e1e05510ac02a5502823bafe46d98c6fab3e5c.tar.gz
puzzles-14e1e05510ac02a5502823bafe46d98c6fab3e5c.tar.bz2
puzzles-14e1e05510ac02a5502823bafe46d98c6fab3e5c.tar.xz
Introduce a new dsf_equivalent() function.
Not very interesting, but the idiom for checking equivalence via two calls to dsf_canonify is cumbersome enough to be worth abbreviating.
Diffstat (limited to 'puzzles.h')
-rw-r--r--puzzles.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/puzzles.h b/puzzles.h
index 358736b..0b7f0cc 100644
--- a/puzzles.h
+++ b/puzzles.h
@@ -439,6 +439,11 @@ int edsf_canonify(DSF *dsf, int val, bool *inverse);
int dsf_canonify(DSF *dsf, int val);
int dsf_size(DSF *dsf, int val);
+/* Check whether two elements are in the same equivalence class.
+ * Equivalent to, but less verbose than, calling dsf_canonify twice
+ * and seeing if their two canonical elements are the same. */
+bool dsf_equivalent(DSF *dsf, int v1, int v2);
+
/* Allow the caller to specify that two elements should be in the same
* equivalence class. If 'inverse' is true, the elements are actually opposite
* to one another in some sense. This function will fail an assertion if the