5 #ifndef FLUTTER_IMPELLER_BASE_COMPARABLE_H_
6 #define FLUTTER_IMPELLER_BASE_COMPARABLE_H_
12 #include <type_traits>
22 return id == other.
id;
31 virtual std::size_t
GetHash()
const = 0;
33 virtual bool IsEqual(
const Type& other)
const = 0;
38 class = std::enable_if_t<std::is_base_of_v<ComparableBase, ComparableType>>>
40 std::size_t
operator()(
const ComparableType&
object)
const {
41 return object.GetHash();
47 class = std::enable_if_t<std::is_base_of_v<ComparableBase, ComparableType>>>
49 bool operator()(
const ComparableType& lhs,
const ComparableType& rhs)
const {
50 return lhs.IsEqual(rhs);
56 class = std::enable_if_t<std::is_base_of_v<ComparableBase, ComparableType>>>
58 const std::shared_ptr<ComparableType>& rhs) {
64 return lhs->IsEqual(*rhs);
73 class = std::enable_if_t<std::is_base_of_v<ComparableBase, ComparableType>>>
74 bool DeepCompareMap(
const std::map<Key, std::shared_ptr<ComparableType>>& lhs,
75 const std::map<Key, std::shared_ptr<ComparableType>>& rhs) {
76 if (lhs.size() != rhs.size()) {
80 for (
auto i = lhs.begin(), j = rhs.begin(); i != lhs.end(); i++, j++) {
81 if (i->first != j->first) {
108 return lhs.
id < rhs.
id;
114 #endif // FLUTTER_IMPELLER_BASE_COMPARABLE_H_