Files
revng-revng/include/revng/MFP/SetLattices.h
2021-12-17 18:51:06 +01:00

31 lines
770 B
C++

#pragma once
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include <algorithm>
template<typename LE>
struct SetUnionLattice {
using LatticeElement = LE;
static LatticeElement
combineValues(const LatticeElement &Left, const LatticeElement &Right) {
LatticeElement Result;
std::set_union(Left.begin(),
Left.end(),
Right.begin(),
Right.end(),
std::inserter(Result, Result.begin()));
return Result;
}
static bool
isLessOrEqual(const LatticeElement &Left, const LatticeElement &Right) {
if (Left.size() > Right.size())
return false;
return std::includes(Right.begin(), Right.end(), Left.begin(), Left.end());
}
};