analyse: add chunk equality comparator
This commit is contained in:
parent
b2731f0968
commit
35a8420d28
@ -13,7 +13,9 @@
|
||||
#include <cruft/util/view.hpp>
|
||||
#include <cruft/util/parse/value.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <compare>
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user