diff --git a/tools/analyse.cpp b/tools/analyse.cpp index 7a1fbf3..e38ae2d 100644 --- a/tools/analyse.cpp +++ b/tools/analyse.cpp @@ -13,7 +13,9 @@ #include #include +#include #include +#include /////////////////////////////////////////////////////////////////////////////// @@ -28,6 +30,41 @@ enum { }; +//----------------------------------------------------------------------------- +static +std::strong_ordering +region_ordering ( + emory::chunk::region const &a, + emory::chunk::region const &b +) { + if (auto const cmp = a.size () <=> b.size (); cmp != 0) + return cmp; + for (int i = 0; i < std::ssize (a.digest); ++i) + if (auto const cmp = a.digest[i] <=> b.digest[i]; cmp != 0) + return cmp; + return std::strong_ordering::equal; +} + + +static bool region_less (emory::chunk::region const &a, emory::chunk::region const &b) +{ + return region_ordering (a, b) < 0; +} + + +static bool region_equal (emory::chunk::region const &a, emory::chunk::region const &b) +{ + return region_ordering (a, b) == 0; +} + + +//static bool overlap (emory::chunk::region const &a, emory::chunk::region const &b) +//{ +// return a.offset.first < b.offset.second && +// b.offset.first < a.offset.second; +//} + + //----------------------------------------------------------------------------- int main (int argc, char const **argv) {