diff --git a/include/loki/details/pddl/action.hpp b/include/loki/details/pddl/action.hpp index ebb205c..4458fe5 100644 --- a/include/loki/details/pddl/action.hpp +++ b/include/loki/details/pddl/action.hpp @@ -60,18 +60,6 @@ class ActionImpl : public Base const std::optional& get_effect() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const ActionImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ActionImpl* l, const ActionImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/atom.hpp b/include/loki/details/pddl/atom.hpp index 816eb8a..8aece8a 100644 --- a/include/loki/details/pddl/atom.hpp +++ b/include/loki/details/pddl/atom.hpp @@ -47,18 +47,6 @@ class AtomImpl : public Base const TermList& get_terms() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const AtomImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const AtomImpl* l, const AtomImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/axiom.hpp b/include/loki/details/pddl/axiom.hpp index a598426..bc6c44b 100644 --- a/include/loki/details/pddl/axiom.hpp +++ b/include/loki/details/pddl/axiom.hpp @@ -51,18 +51,6 @@ class AxiomImpl : public Base size_t get_num_parameters_to_ground_head() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const AxiomImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const AxiomImpl* l, const AxiomImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/base.hpp b/include/loki/details/pddl/base.hpp index 44dd62a..858ff70 100644 --- a/include/loki/details/pddl/base.hpp +++ b/include/loki/details/pddl/base.hpp @@ -47,10 +47,6 @@ class Base Base(Base&& other) = default; Base& operator=(Base&& other) = default; - bool operator<(const Base& other) const { return m_index < other.m_index; } - - bool operator>(const Base& other) const { return m_index > other.m_index; } - /// @brief Overload of the output stream insertion operator (operator<<). friend std::ostream& operator<<(std::ostream& os, const Base& element) { diff --git a/include/loki/details/pddl/conditions.hpp b/include/loki/details/pddl/conditions.hpp index f89e88b..23eb012 100644 --- a/include/loki/details/pddl/conditions.hpp +++ b/include/loki/details/pddl/conditions.hpp @@ -47,18 +47,6 @@ class ConditionLiteralImpl : public Base const Literal& get_literal() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const ConditionLiteralImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ConditionLiteralImpl& l, const ConditionLiteralImpl& r) const; -}; - /* And */ class ConditionAndImpl : public Base { @@ -80,18 +68,6 @@ class ConditionAndImpl : public Base const ConditionList& get_conditions() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const ConditionAndImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ConditionAndImpl& l, const ConditionAndImpl& r) const; -}; - /* Or */ class ConditionOrImpl : public Base { @@ -115,18 +91,6 @@ class ConditionOrImpl : public Base const ConditionList& get_conditions() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const ConditionOrImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ConditionOrImpl& l, const ConditionOrImpl& r) const; -}; - /* Not */ class ConditionNotImpl : public Base { @@ -148,18 +112,6 @@ class ConditionNotImpl : public Base const Condition& get_condition() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const ConditionNotImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ConditionNotImpl& l, const ConditionNotImpl& r) const; -}; - /* Imply */ class ConditionImplyImpl : public Base { @@ -183,18 +135,6 @@ class ConditionImplyImpl : public Base const Condition& get_condition_right() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const ConditionImplyImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ConditionImplyImpl& l, const ConditionImplyImpl& r) const; -}; - /* Exists */ class ConditionExistsImpl : public Base { @@ -218,18 +158,6 @@ class ConditionExistsImpl : public Base const Condition& get_condition() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const ConditionExistsImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ConditionExistsImpl& l, const ConditionExistsImpl& r) const; -}; - /* Forall */ class ConditionForallImpl : public Base { @@ -253,32 +181,6 @@ class ConditionForallImpl : public Base const Condition& get_condition() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const ConditionForallImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ConditionForallImpl& l, const ConditionForallImpl& r) const; -}; - -/* ConditionImpl */ - -template<> -struct ShallowHash -{ - size_t operator()(const ConditionImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ConditionImpl* l, const ConditionImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/declarations.hpp b/include/loki/details/pddl/declarations.hpp index 6bb0aff..0ab0a1b 100644 --- a/include/loki/details/pddl/declarations.hpp +++ b/include/loki/details/pddl/declarations.hpp @@ -38,9 +38,9 @@ using PDDLElement = const T*; */ template -struct ShallowHash; +struct Hasher; template -struct ShallowEqualTo; +struct EqualTo; template class UniqueFactory; diff --git a/include/loki/details/pddl/domain.hpp b/include/loki/details/pddl/domain.hpp index 471a3ea..b031689 100644 --- a/include/loki/details/pddl/domain.hpp +++ b/include/loki/details/pddl/domain.hpp @@ -73,18 +73,6 @@ class DomainImpl : public Base const AxiomList& get_axioms() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const DomainImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const DomainImpl* l, const DomainImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/effects.hpp b/include/loki/details/pddl/effects.hpp index 13e7d78..6726195 100644 --- a/include/loki/details/pddl/effects.hpp +++ b/include/loki/details/pddl/effects.hpp @@ -58,18 +58,6 @@ class EffectLiteralImpl : public Base const Literal& get_literal() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const EffectLiteralImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const EffectLiteralImpl& l, const EffectLiteralImpl& r) const; -}; - /* And */ class EffectAndImpl : public Base { @@ -91,18 +79,6 @@ class EffectAndImpl : public Base const EffectList& get_effects() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const EffectAndImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const EffectAndImpl& l, const EffectAndImpl& r) const; -}; - /* EffectNumeric */ class EffectNumericImpl : public Base { @@ -128,18 +104,6 @@ class EffectNumericImpl : public Base const FunctionExpression& get_function_expression() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const EffectNumericImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const EffectNumericImpl& l, const EffectNumericImpl& r) const; -}; - /* ConditionalForall */ class EffectConditionalForallImpl : public Base { @@ -163,18 +127,6 @@ class EffectConditionalForallImpl : public Base const Effect& get_effect() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const EffectConditionalForallImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const EffectConditionalForallImpl& l, const EffectConditionalForallImpl& r) const; -}; - /* ConditionalWhen */ class EffectConditionalWhenImpl : public Base { @@ -198,32 +150,6 @@ class EffectConditionalWhenImpl : public Base const Effect& get_effect() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const EffectConditionalWhenImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const EffectConditionalWhenImpl& l, const EffectConditionalWhenImpl& r) const; -}; - -/* EffectImpl */ - -template<> -struct ShallowHash -{ - size_t operator()(const EffectImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const EffectImpl* l, const EffectImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/factories.hpp b/include/loki/details/pddl/factories.hpp index 1b6e120..1b6c46e 100644 --- a/include/loki/details/pddl/factories.hpp +++ b/include/loki/details/pddl/factories.hpp @@ -46,28 +46,26 @@ namespace loki { -using RequirementsFactory = UniqueFactory, ShallowEqualTo>; -using TypeFactory = UniqueFactory, ShallowEqualTo>; -using VariableFactory = UniqueFactory, ShallowEqualTo>; -using TermFactory = UniqueFactory, ShallowEqualTo>; -using ObjectFactory = UniqueFactory, ShallowEqualTo>; -using AtomFactory = UniqueFactory, ShallowEqualTo>; -using LiteralFactory = UniqueFactory, ShallowEqualTo>; -using ParameterFactory = UniqueFactory, ShallowEqualTo>; -using PredicateFactory = UniqueFactory, ShallowEqualTo>; -using FunctionExpressionFactory = - UniqueFactory, ShallowEqualTo>; -using FunctionFactory = UniqueFactory, ShallowEqualTo>; -using FunctionSkeletonFactory = UniqueFactory, ShallowEqualTo>; -using ConditionFactory = UniqueFactory, ShallowEqualTo>; -using EffectFactory = UniqueFactory, ShallowEqualTo>; -using ActionFactory = UniqueFactory, ShallowEqualTo>; -using AxiomFactory = UniqueFactory, ShallowEqualTo>; -using OptimizationMetricFactory = - UniqueFactory, ShallowEqualTo>; -using NumericFluentFactory = UniqueFactory, ShallowEqualTo>; -using DomainFactory = UniqueFactory, ShallowEqualTo>; -using ProblemFactory = UniqueFactory, ShallowEqualTo>; +using RequirementsFactory = UniqueFactory, EqualTo>; +using TypeFactory = UniqueFactory, EqualTo>; +using VariableFactory = UniqueFactory, EqualTo>; +using TermFactory = UniqueFactory, EqualTo>; +using ObjectFactory = UniqueFactory, EqualTo>; +using AtomFactory = UniqueFactory, EqualTo>; +using LiteralFactory = UniqueFactory, EqualTo>; +using ParameterFactory = UniqueFactory, EqualTo>; +using PredicateFactory = UniqueFactory, EqualTo>; +using FunctionExpressionFactory = UniqueFactory, EqualTo>; +using FunctionFactory = UniqueFactory, EqualTo>; +using FunctionSkeletonFactory = UniqueFactory, EqualTo>; +using ConditionFactory = UniqueFactory, EqualTo>; +using EffectFactory = UniqueFactory, EqualTo>; +using ActionFactory = UniqueFactory, EqualTo>; +using AxiomFactory = UniqueFactory, EqualTo>; +using OptimizationMetricFactory = UniqueFactory, EqualTo>; +using NumericFluentFactory = UniqueFactory, EqualTo>; +using DomainFactory = UniqueFactory, EqualTo>; +using ProblemFactory = UniqueFactory, EqualTo>; using VariadicPDDLConstructorFactory = VariadicContainer const TermList& get_terms() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const FunctionImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const FunctionImpl* l, const FunctionImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/function_expressions.hpp b/include/loki/details/pddl/function_expressions.hpp index dab869b..c786fbe 100644 --- a/include/loki/details/pddl/function_expressions.hpp +++ b/include/loki/details/pddl/function_expressions.hpp @@ -67,18 +67,6 @@ class FunctionExpressionNumberImpl : public Base double get_number() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const FunctionExpressionNumberImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const FunctionExpressionNumberImpl& l, const FunctionExpressionNumberImpl& r) const; -}; - /* FunctionExpressionBinaryOperator */ class FunctionExpressionBinaryOperatorImpl : public Base { @@ -107,18 +95,6 @@ class FunctionExpressionBinaryOperatorImpl : public Base -struct ShallowHash -{ - size_t operator()(const FunctionExpressionBinaryOperatorImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const FunctionExpressionBinaryOperatorImpl& l, const FunctionExpressionBinaryOperatorImpl& r) const; -}; - /* FunctionExpressionMultiOperator */ class FunctionExpressionMultiOperatorImpl : public Base { @@ -142,18 +118,6 @@ class FunctionExpressionMultiOperatorImpl : public Base -struct ShallowHash -{ - size_t operator()(const FunctionExpressionMultiOperatorImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const FunctionExpressionMultiOperatorImpl& l, const FunctionExpressionMultiOperatorImpl& r) const; -}; - /* FunctionExpressionMinus */ class FunctionExpressionMinusImpl : public Base { @@ -175,18 +139,6 @@ class FunctionExpressionMinusImpl : public Base const FunctionExpression& get_function_expression() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const FunctionExpressionMinusImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const FunctionExpressionMinusImpl& l, const FunctionExpressionMinusImpl& r) const; -}; - /* FunctionExpressionFunction */ class FunctionExpressionFunctionImpl : public Base { @@ -208,32 +160,6 @@ class FunctionExpressionFunctionImpl : public Base -struct ShallowHash -{ - size_t operator()(const FunctionExpressionFunctionImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const FunctionExpressionFunctionImpl& l, const FunctionExpressionFunctionImpl& r) const; -}; - -/* FunctionExpressionImpl */ - -template<> -struct ShallowHash -{ - size_t operator()(const FunctionExpressionImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const FunctionExpressionImpl* l, const FunctionExpressionImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/function_skeleton.hpp b/include/loki/details/pddl/function_skeleton.hpp index 4eb4730..1a1488b 100644 --- a/include/loki/details/pddl/function_skeleton.hpp +++ b/include/loki/details/pddl/function_skeleton.hpp @@ -49,18 +49,6 @@ class FunctionSkeletonImpl : public Base const Type& get_type() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const FunctionSkeletonImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const FunctionSkeletonImpl* l, const FunctionSkeletonImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/literal.hpp b/include/loki/details/pddl/literal.hpp index 24aa715..9d3bb17 100644 --- a/include/loki/details/pddl/literal.hpp +++ b/include/loki/details/pddl/literal.hpp @@ -46,19 +46,6 @@ class LiteralImpl : public Base bool is_negated() const; const Atom& get_atom() const; }; - -template<> -struct ShallowHash -{ - size_t operator()(const LiteralImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const LiteralImpl* l, const LiteralImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/metric.hpp b/include/loki/details/pddl/metric.hpp index 20002b0..dabad58 100644 --- a/include/loki/details/pddl/metric.hpp +++ b/include/loki/details/pddl/metric.hpp @@ -55,19 +55,6 @@ class OptimizationMetricImpl : public Base OptimizationMetricEnum get_optimization_metric() const; const FunctionExpression& get_function_expression() const; }; - -template<> -struct ShallowHash -{ - size_t operator()(const OptimizationMetricImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const OptimizationMetricImpl* l, const OptimizationMetricImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/numeric_fluent.hpp b/include/loki/details/pddl/numeric_fluent.hpp index 9af54f1..0a70529 100644 --- a/include/loki/details/pddl/numeric_fluent.hpp +++ b/include/loki/details/pddl/numeric_fluent.hpp @@ -47,18 +47,6 @@ class NumericFluentImpl : public Base double get_number() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const NumericFluentImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const NumericFluentImpl* l, const NumericFluentImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/object.hpp b/include/loki/details/pddl/object.hpp index d42a4be..7897b67 100644 --- a/include/loki/details/pddl/object.hpp +++ b/include/loki/details/pddl/object.hpp @@ -47,18 +47,6 @@ class ObjectImpl : public Base const TypeList& get_bases() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const ObjectImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ObjectImpl* l, const ObjectImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/parameter.hpp b/include/loki/details/pddl/parameter.hpp index e35246a..46ae828 100644 --- a/include/loki/details/pddl/parameter.hpp +++ b/include/loki/details/pddl/parameter.hpp @@ -48,18 +48,6 @@ class ParameterImpl : public Base const TypeList& get_bases() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const ParameterImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ParameterImpl* l, const ParameterImpl* r) const; -}; - /// @brief Return true iff specialized_parameter is a specialized version of generalized_parameter /// by checking whether the types are compatible extern bool is_specialized_parameter(const Parameter& specialized_parameter, const Parameter& generalized_parameter); diff --git a/include/loki/details/pddl/predicate.hpp b/include/loki/details/pddl/predicate.hpp index adf25ba..2d46ecc 100644 --- a/include/loki/details/pddl/predicate.hpp +++ b/include/loki/details/pddl/predicate.hpp @@ -49,18 +49,6 @@ class PredicateImpl : public Base const ParameterList& get_parameters() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const PredicateImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const PredicateImpl* l, const PredicateImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/problem.hpp b/include/loki/details/pddl/problem.hpp index a7953f6..c07e09e 100644 --- a/include/loki/details/pddl/problem.hpp +++ b/include/loki/details/pddl/problem.hpp @@ -78,18 +78,6 @@ class ProblemImpl : public Base const AxiomList& get_axioms() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const ProblemImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const ProblemImpl* l, const ProblemImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/requirements.hpp b/include/loki/details/pddl/requirements.hpp index 1b948c1..011c442 100644 --- a/include/loki/details/pddl/requirements.hpp +++ b/include/loki/details/pddl/requirements.hpp @@ -78,18 +78,6 @@ class RequirementsImpl : public Base const RequirementEnumSet& get_requirements() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const RequirementsImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const RequirementsImpl* l, const RequirementsImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/term.hpp b/include/loki/details/pddl/term.hpp index 3110de8..88d3eb1 100644 --- a/include/loki/details/pddl/term.hpp +++ b/include/loki/details/pddl/term.hpp @@ -48,18 +48,6 @@ class TermObjectImpl : public Base const Object& get_object() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const TermObjectImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const TermObjectImpl& l, const TermObjectImpl& r) const; -}; - /* TermVariableImpl */ class TermVariableImpl : public Base @@ -82,32 +70,6 @@ class TermVariableImpl : public Base const Variable& get_variable() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const TermVariableImpl& e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const TermVariableImpl& l, const TermVariableImpl& r) const; -}; - -/* TermImpl */ - -template<> -struct ShallowHash -{ - size_t operator()(const TermImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const TermImpl* l, const TermImpl* r) const; -}; - } #endif diff --git a/include/loki/details/pddl/type.hpp b/include/loki/details/pddl/type.hpp index bee48cc..876d479 100644 --- a/include/loki/details/pddl/type.hpp +++ b/include/loki/details/pddl/type.hpp @@ -47,18 +47,6 @@ class TypeImpl : public Base const TypeList& get_bases() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const TypeImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const TypeImpl* l, const TypeImpl* r) const; -}; - /// @brief Collects all types from a hierarchy. extern TypeSet collect_types_from_hierarchy(const TypeList& types); diff --git a/include/loki/details/pddl/variable.hpp b/include/loki/details/pddl/variable.hpp index c1feb34..7ea0567 100644 --- a/include/loki/details/pddl/variable.hpp +++ b/include/loki/details/pddl/variable.hpp @@ -45,18 +45,6 @@ class VariableImpl : public Base const std::string& get_name() const; }; -template<> -struct ShallowHash -{ - size_t operator()(const VariableImpl* e) const; -}; - -template<> -struct ShallowEqualTo -{ - bool operator()(const VariableImpl* l, const VariableImpl* r) const; -}; - extern VariableSet collect_free_variables(const loki::ConditionImpl& condition); } diff --git a/include/loki/details/utils/equal_to.hpp b/include/loki/details/utils/equal_to.hpp index e036955..ec07538 100644 --- a/include/loki/details/utils/equal_to.hpp +++ b/include/loki/details/utils/equal_to.hpp @@ -18,6 +18,7 @@ #ifndef LOKI_INCLUDE_LOKI_UTILS_EQUAL_TO_HPP_ #define LOKI_INCLUDE_LOKI_UTILS_EQUAL_TO_HPP_ +#include "loki/details/pddl/declarations.hpp" #include "loki/details/utils/concepts.hpp" #include @@ -25,19 +26,19 @@ namespace loki { -/// @brief `ShallowEqualTo` is a comparator that should be implemented to work in the context where +/// @brief `EqualTo` is a comparator that should be implemented to work in the context where /// all objects of a custom type `T` are uniquely created and uncopieable. /// This ensures that pointers can simply be compared and do not need to be dereferenced. /// @tparam T the type of the object to compare. template -struct ShallowEqualTo +struct EqualTo { bool operator()(const T& l, const T& r) const { return std::equal_to()(l, r); } }; /// Spezialization for std::variant. template -struct ShallowEqualTo> +struct EqualTo> { bool operator()(const std::variant& l, const std::variant& r) const { @@ -51,7 +52,7 @@ struct ShallowEqualTo> { if constexpr (std::is_same_v) { - return ShallowEqualTo()(lhs, rhs); + return EqualTo()(lhs, rhs); } else { @@ -63,6 +64,237 @@ struct ShallowEqualTo> } }; +/** + * Specializations for PDDL + */ + +template<> +struct EqualTo +{ + bool operator()(const ActionImpl* l, const ActionImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const AtomImpl* l, const AtomImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const AxiomImpl* l, const AxiomImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const ConditionLiteralImpl& l, const ConditionLiteralImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const ConditionAndImpl& l, const ConditionAndImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const ConditionOrImpl& l, const ConditionOrImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const ConditionNotImpl& l, const ConditionNotImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const ConditionImplyImpl& l, const ConditionImplyImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const ConditionExistsImpl& l, const ConditionExistsImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const ConditionForallImpl& l, const ConditionForallImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const ConditionImpl* l, const ConditionImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const DomainImpl* l, const DomainImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const EffectLiteralImpl& l, const EffectLiteralImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const EffectAndImpl& l, const EffectAndImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const EffectNumericImpl& l, const EffectNumericImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const EffectConditionalForallImpl& l, const EffectConditionalForallImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const EffectConditionalWhenImpl& l, const EffectConditionalWhenImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const EffectImpl* l, const EffectImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const FunctionExpressionNumberImpl& l, const FunctionExpressionNumberImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const FunctionExpressionBinaryOperatorImpl& l, const FunctionExpressionBinaryOperatorImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const FunctionExpressionMultiOperatorImpl& l, const FunctionExpressionMultiOperatorImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const FunctionExpressionMinusImpl& l, const FunctionExpressionMinusImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const FunctionExpressionFunctionImpl& l, const FunctionExpressionFunctionImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const FunctionExpressionImpl* l, const FunctionExpressionImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const FunctionImpl* l, const FunctionImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const LiteralImpl* l, const LiteralImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const OptimizationMetricImpl* l, const OptimizationMetricImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const NumericFluentImpl* l, const NumericFluentImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const ObjectImpl* l, const ObjectImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const ParameterImpl* l, const ParameterImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const PredicateImpl* l, const PredicateImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const ProblemImpl* l, const ProblemImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const RequirementsImpl* l, const RequirementsImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const TermObjectImpl& l, const TermObjectImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const TermVariableImpl& l, const TermVariableImpl& r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const TermImpl* l, const TermImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const TypeImpl* l, const TypeImpl* r) const; +}; + +template<> +struct EqualTo +{ + bool operator()(const VariableImpl* l, const VariableImpl* r) const; +}; } #endif diff --git a/include/loki/details/utils/hash.hpp b/include/loki/details/utils/hash.hpp index 55d41ad..7a49569 100644 --- a/include/loki/details/utils/hash.hpp +++ b/include/loki/details/utils/hash.hpp @@ -18,6 +18,7 @@ #ifndef LOKI_INCLUDE_LOKI_UTILS_HASH_HPP_ #define LOKI_INCLUDE_LOKI_UTILS_HASH_HPP_ +#include "loki/details/pddl/declarations.hpp" #include "loki/details/utils/concepts.hpp" #include @@ -29,23 +30,23 @@ namespace loki { -/// @brief `ShallowHash` is a hasher that should be implemented to work in the context where +/// @brief `Hasher` is a hasher that should be implemented to work in the context where /// all objects of a custom type `T` are uniquely created and uncopieable. /// This ensures that pointers can simply be hashed and do not need to be dereferenced. /// @tparam T the type of the object to hash. template -struct ShallowHash +struct Hasher { size_t operator()(const T& element) const { return std::hash()(element); } }; -struct ShallowHashCombiner +struct HashCombiner { public: template void operator()(size_t& seed, const T& value) const { - seed ^= ShallowHash()(value) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + seed ^= Hasher()(value) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } void operator()(size_t& seed, const std::size_t& value) const { seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2); } @@ -62,14 +63,14 @@ struct ShallowHashCombiner /// Spezialization for std::ranges::forward_range. template requires std::ranges::forward_range -struct ShallowHash +struct Hasher { size_t operator()(const ForwardRange& range) const { std::size_t aggregated_hash = 0; for (const auto& item : range) { - ShallowHashCombiner()(aggregated_hash, item); + HashCombiner()(aggregated_hash, item); } return aggregated_hash; } @@ -78,14 +79,252 @@ struct ShallowHash /// Spezialization for std::variant. template requires IsVariant -struct ShallowHash +struct Hasher { size_t operator()(const Variant& variant) const { - return std::visit([](const auto& arg) { return ShallowHash()(arg); }, variant); + return std::visit([](const auto& arg) { return Hasher()(arg); }, variant); } }; +/** + * Specializations for PDDL + */ + +template<> +struct Hasher +{ + size_t operator()(const ActionImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const AtomImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const AxiomImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const ConditionLiteralImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const ConditionAndImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const ConditionOrImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const ConditionNotImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const ConditionImplyImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const ConditionExistsImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const ConditionForallImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const ConditionImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const DomainImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const EffectLiteralImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const EffectAndImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const EffectNumericImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const EffectConditionalForallImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const EffectConditionalWhenImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const EffectImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const FunctionExpressionNumberImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const FunctionExpressionBinaryOperatorImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const FunctionExpressionMultiOperatorImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const FunctionExpressionMinusImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const FunctionExpressionFunctionImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const FunctionExpressionImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const FunctionSkeletonImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const FunctionImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const LiteralImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const OptimizationMetricImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const NumericFluentImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const ObjectImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const ParameterImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const PredicateImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const ProblemImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const RequirementsImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const TermObjectImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const TermVariableImpl& e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const TermImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const TypeImpl* e) const; +}; + +template<> +struct Hasher +{ + size_t operator()(const VariableImpl* e) const; +}; + } #endif diff --git a/include/loki/details/utils/unique_factory.hpp b/include/loki/details/utils/unique_factory.hpp index 744b181..efec3c8 100644 --- a/include/loki/details/utils/unique_factory.hpp +++ b/include/loki/details/utils/unique_factory.hpp @@ -36,14 +36,14 @@ namespace loki /// uniqueness checks and SegmentedVector for continuous and cache-efficient storage of value types. /// @tparam HolderType is the holder value type which can be an std::variant. /// Note that using a base class value type will result in object slicing. -/// @tparam Hash the hash function, default uses `ShallowHash` hasher. -/// @tparam EqualTo the comparison function, default uses `ShallowEqualTo` comparator. -template, typename EqualTo = ShallowEqualTo> +/// @tparam Hash the hash function, default uses `Hasher` hasher. +/// @tparam KeyEqual the comparison function, default uses `EqualTo` comparator. +template, typename KeyEqual = EqualTo> class UniqueFactory { private: // We use an unordered_set to test for uniqueness. - std::unordered_set m_uniqueness_set; + std::unordered_set m_uniqueness_set; // We use pre-allocated memory to store objects persistent. SegmentedVector m_persistent_vector; @@ -68,11 +68,11 @@ class UniqueFactory UniqueFactory& operator=(UniqueFactory&& other) = default; /// @brief Returns a pointer to an existing object or creates it before if it does not exist. - /// The `SubType` is not allowed to be copieable because `ShallowHash` and `ShallowEqualTo` + /// The `SubType` is not allowed to be copieable because `Hasher` and `EqualTo` /// is implemented to hash and compare simply the pointers. - /// The `HolderType` is allowed to be copieable but `ShallowHash` and `ShallowEqualTo` + /// The `HolderType` is allowed to be copieable but `Hasher` and `EqualTo` /// will have to take this into account by hashing and comparing the nested `SubType`. - /// For example, if `HolderType` is a std::variant, then `ShallowHash` and `ShallowEqual` + /// For example, if `HolderType` is a std::variant, then `Hasher` and `ShallowEqual` /// will hash or compare the nested `SubType` object. template requires(!std::is_copy_constructible_v) HolderType const* get_or_create(Args&&... args) diff --git a/src/pddl/action.cpp b/src/pddl/action.cpp index e97df23..135bf61 100644 --- a/src/pddl/action.cpp +++ b/src/pddl/action.cpp @@ -21,9 +21,6 @@ #include "loki/details/pddl/effects.hpp" #include "loki/details/pddl/parameter.hpp" #include "loki/details/pddl/visitors.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" namespace loki { @@ -80,18 +77,4 @@ const std::optional& ActionImpl::get_condition() const { return m_con const std::optional& ActionImpl::get_effect() const { return m_effect; } -size_t ShallowHash::operator()(const ActionImpl* e) const -{ - return ShallowHashCombiner()(e->get_name(), get_sorted_vector(e->get_parameters()), e->get_condition(), e->get_effect()); -} - -bool ShallowEqualTo::operator()(const ActionImpl* l, const ActionImpl* r) const -{ - if (&l != &r) - { - return (l->get_name() == r->get_name()) && (get_sorted_vector(l->get_parameters()) == get_sorted_vector(r->get_parameters())) - && (l->get_condition() == r->get_condition()) && (l->get_effect() == r->get_effect()); - } - return true; -} } diff --git a/src/pddl/atom.cpp b/src/pddl/atom.cpp index b732669..a83b50e 100644 --- a/src/pddl/atom.cpp +++ b/src/pddl/atom.cpp @@ -20,9 +20,6 @@ #include "loki/details/pddl/predicate.hpp" #include "loki/details/pddl/term.hpp" #include "loki/details/pddl/visitors.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" namespace loki { @@ -43,15 +40,4 @@ const Predicate& AtomImpl::get_predicate() const { return m_predicate; } const TermList& AtomImpl::get_terms() const { return m_terms; } -size_t ShallowHash::operator()(const AtomImpl* e) const { return ShallowHashCombiner()(e->get_predicate(), e->get_terms()); } - -bool ShallowEqualTo::operator()(const AtomImpl* l, const AtomImpl* r) const -{ - if (&l != &r) - { - return (l->get_predicate() == r->get_predicate()) && (l->get_terms() == r->get_terms()); - } - return true; -} - } diff --git a/src/pddl/axiom.cpp b/src/pddl/axiom.cpp index 31dbdcd..d8ff477 100644 --- a/src/pddl/axiom.cpp +++ b/src/pddl/axiom.cpp @@ -23,9 +23,6 @@ #include "loki/details/pddl/parameter.hpp" #include "loki/details/pddl/predicate.hpp" #include "loki/details/pddl/visitors.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" namespace loki { @@ -61,19 +58,4 @@ const ParameterList& AxiomImpl::get_parameters() const { return m_parameters; } size_t AxiomImpl::get_num_parameters_to_ground_head() const { return m_num_parameters_to_ground_head; } -size_t ShallowHash::operator()(const AxiomImpl* e) const -{ - return ShallowHashCombiner()(e->get_derived_predicate_name(), get_sorted_vector(e->get_parameters()), e->get_condition()); -} - -bool ShallowEqualTo::operator()(const AxiomImpl* l, const AxiomImpl* r) const -{ - if (&l != &r) - { - return (l->get_derived_predicate_name() == r->get_derived_predicate_name()) - && (get_sorted_vector(l->get_parameters()) == get_sorted_vector(r->get_parameters())) && (l->get_condition() == r->get_condition()); - } - return true; -} - } diff --git a/src/pddl/conditions.cpp b/src/pddl/conditions.cpp index 95a1882..855279a 100644 --- a/src/pddl/conditions.cpp +++ b/src/pddl/conditions.cpp @@ -20,9 +20,6 @@ #include "loki/details/pddl/literal.hpp" #include "loki/details/pddl/parameter.hpp" #include "loki/details/pddl/visitors.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" namespace loki { @@ -34,17 +31,6 @@ void ConditionLiteralImpl::str_impl(std::ostream& out, const FormattingOptions& const Literal& ConditionLiteralImpl::get_literal() const { return m_literal; } -size_t ShallowHash::operator()(const ConditionLiteralImpl& e) const { return ShallowHashCombiner()(e.get_literal()); } - -bool ShallowEqualTo::operator()(const ConditionLiteralImpl& l, const ConditionLiteralImpl& r) const -{ - if (&l != &r) - { - return (l.get_literal() == r.get_literal()); - } - return true; -} - /* And */ ConditionAndImpl::ConditionAndImpl(size_t index, ConditionList conditions) : Base(index), m_conditions(std::move(conditions)) {} @@ -62,20 +48,6 @@ void ConditionAndImpl::str_impl(std::ostream& out, const FormattingOptions& opti const ConditionList& ConditionAndImpl::get_conditions() const { return m_conditions; } -size_t ShallowHash::operator()(const ConditionAndImpl& e) const -{ - return ShallowHashCombiner()(get_sorted_vector(e.get_conditions())); -} - -bool ShallowEqualTo::operator()(const ConditionAndImpl& l, const ConditionAndImpl& r) const -{ - if (&l != &r) - { - return (get_sorted_vector(l.get_conditions()) == get_sorted_vector(r.get_conditions())); - } - return true; -} - /* Or */ ConditionOrImpl::ConditionOrImpl(size_t index, ConditionList conditions) : Base(index), m_conditions(std::move(conditions)) {} @@ -93,17 +65,6 @@ void ConditionOrImpl::str_impl(std::ostream& out, const FormattingOptions& optio const ConditionList& ConditionOrImpl::get_conditions() const { return m_conditions; } -size_t ShallowHash::operator()(const ConditionOrImpl& e) const { return ShallowHashCombiner()(get_sorted_vector(e.get_conditions())); } - -bool ShallowEqualTo::operator()(const ConditionOrImpl& l, const ConditionOrImpl& r) const -{ - if (&l != &r) - { - return (get_sorted_vector(l.get_conditions()) == get_sorted_vector(r.get_conditions())); - } - return true; -} - /* Not */ ConditionNotImpl::ConditionNotImpl(size_t index, Condition condition) : Base(index), m_condition(std::move(condition)) {} @@ -116,17 +77,6 @@ void ConditionNotImpl::str_impl(std::ostream& out, const FormattingOptions& opti const Condition& ConditionNotImpl::get_condition() const { return m_condition; } -size_t ShallowHash::operator()(const ConditionNotImpl& e) const { return ShallowHashCombiner()(e.get_condition()); } - -bool ShallowEqualTo::operator()(const ConditionNotImpl& l, const ConditionNotImpl& r) const -{ - if (&l != &r) - { - return (l.get_condition() == r.get_condition()); - } - return true; -} - /* Imply */ ConditionImplyImpl::ConditionImplyImpl(size_t index, Condition condition_left, Condition condition_right) : Base(index), @@ -148,20 +98,6 @@ const Condition& ConditionImplyImpl::get_condition_left() const { return m_condi const Condition& ConditionImplyImpl::get_condition_right() const { return m_condition_right; } -size_t ShallowHash::operator()(const ConditionImplyImpl& e) const -{ - return ShallowHashCombiner()(e.get_condition_left(), e.get_condition_right()); -} - -bool ShallowEqualTo::operator()(const ConditionImplyImpl& l, const ConditionImplyImpl& r) const -{ - if (&l != &r) - { - return (l.get_condition_left() == r.get_condition_left()) && (l.get_condition_left() == r.get_condition_left()); - } - return true; -} - /* Exists */ ConditionExistsImpl::ConditionExistsImpl(size_t index, ParameterList parameters, Condition condition) : Base(index), @@ -188,20 +124,6 @@ const ParameterList& ConditionExistsImpl::get_parameters() const { return m_para const Condition& ConditionExistsImpl::get_condition() const { return m_condition; } -size_t ShallowHash::operator()(const ConditionExistsImpl& e) const -{ - return ShallowHashCombiner()(get_sorted_vector(e.get_parameters()), e.get_condition()); -} - -bool ShallowEqualTo::operator()(const ConditionExistsImpl& l, const ConditionExistsImpl& r) const -{ - if (&l != &r) - { - return (l.get_condition() == r.get_condition()) && (get_sorted_vector(l.get_parameters()) == get_sorted_vector(r.get_parameters())); - } - return true; -} - /* Forall */ ConditionForallImpl::ConditionForallImpl(size_t index, ParameterList parameters, Condition condition) : Base(index), @@ -228,27 +150,4 @@ const ParameterList& ConditionForallImpl::get_parameters() const { return m_para const Condition& ConditionForallImpl::get_condition() const { return m_condition; } -size_t ShallowHash::operator()(const ConditionForallImpl& e) const -{ - return ShallowHashCombiner()(get_sorted_vector(e.get_parameters()), e.get_condition()); -} - -bool ShallowEqualTo::operator()(const ConditionForallImpl& l, const ConditionForallImpl& r) const -{ - if (&l != &r) - { - return (l.get_condition() == r.get_condition()) && (get_sorted_vector(l.get_parameters()) == get_sorted_vector(r.get_parameters())); - } - return true; -} - -/* ConditionImpl */ - -size_t ShallowHash::operator()(const ConditionImpl* e) const -{ - return std::visit([](const auto& arg) { return ShallowHash()(arg); }, *e); -} - -bool ShallowEqualTo::operator()(const ConditionImpl* l, const ConditionImpl* r) const { return ShallowEqualTo()(*l, *r); } - } diff --git a/src/pddl/domain.cpp b/src/pddl/domain.cpp index 083dffd..225577a 100644 --- a/src/pddl/domain.cpp +++ b/src/pddl/domain.cpp @@ -24,7 +24,6 @@ #include "loki/details/pddl/predicate.hpp" #include "loki/details/pddl/requirements.hpp" #include "loki/details/pddl/type.hpp" -#include "loki/details/utils/collections.hpp" #include "loki/details/utils/equal_to.hpp" #include "loki/details/utils/hash.hpp" @@ -70,7 +69,7 @@ void DomainImpl::str_impl(std::ostream& out, const FormattingOptions& options) c if (!m_types.empty()) { out << string(nested_options.indent, ' ') << "(:types "; - std::unordered_map> subtypes_by_parent_types; + std::unordered_map> subtypes_by_parent_types; for (const auto& type : m_types) { // We do not want to print root type "object" @@ -113,7 +112,7 @@ void DomainImpl::str_impl(std::ostream& out, const FormattingOptions& options) c if (!m_constants.empty()) { out << string(nested_options.indent, ' ') << "(:constants "; - std::unordered_map> constants_by_types; + std::unordered_map> constants_by_types; for (const auto& constant : m_constants) { constants_by_types[constant->get_bases()].push_back(constant); @@ -204,31 +203,4 @@ const ActionList& DomainImpl::get_actions() const { return m_actions; } const AxiomList& DomainImpl::get_axioms() const { return m_axioms; } -size_t ShallowHash::operator()(const DomainImpl* e) const -{ - return ShallowHashCombiner()(e->get_name(), - e->get_requirements(), - get_sorted_vector(e->get_types()), - get_sorted_vector(e->get_constants()), - get_sorted_vector(e->get_predicates()), - get_sorted_vector(e->get_functions()), - get_sorted_vector(e->get_actions()), - get_sorted_vector(e->get_axioms())); -} - -bool ShallowEqualTo::operator()(const DomainImpl* l, const DomainImpl* r) const -{ - if (&l != &r) - { - return (l->get_name() == r->get_name()) && (l->get_requirements() == r->get_requirements()) - && (get_sorted_vector(l->get_types()) == get_sorted_vector(r->get_types())) - && (get_sorted_vector(l->get_constants()) == get_sorted_vector(r->get_constants())) - && (get_sorted_vector(l->get_predicates()) == get_sorted_vector(r->get_predicates())) - && (get_sorted_vector(l->get_functions()) == get_sorted_vector(r->get_functions())) - && (get_sorted_vector(l->get_actions()) == get_sorted_vector(r->get_actions())) - && (get_sorted_vector(l->get_axioms()) == get_sorted_vector(r->get_axioms())); - } - return true; -} - } diff --git a/src/pddl/effects.cpp b/src/pddl/effects.cpp index bacc1e2..635f3ea 100644 --- a/src/pddl/effects.cpp +++ b/src/pddl/effects.cpp @@ -23,9 +23,6 @@ #include "loki/details/pddl/literal.hpp" #include "loki/details/pddl/parameter.hpp" #include "loki/details/pddl/visitors.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" #include @@ -50,17 +47,6 @@ void EffectLiteralImpl::str_impl(std::ostream& out, const FormattingOptions& opt const Literal& EffectLiteralImpl::get_literal() const { return m_literal; } -size_t ShallowHash::operator()(const EffectLiteralImpl& e) const { return ShallowHashCombiner()(e.get_literal()); } - -bool ShallowEqualTo::operator()(const EffectLiteralImpl& l, const EffectLiteralImpl& r) const -{ - if (&l != &r) - { - return (l.get_literal() == r.get_literal()); - } - return true; -} - /* EffectAnd */ EffectAndImpl::EffectAndImpl(size_t index, EffectList effects) : Base(index), m_effects(std::move(effects)) {} @@ -78,17 +64,6 @@ void EffectAndImpl::str_impl(std::ostream& out, const FormattingOptions& options const EffectList& EffectAndImpl::get_effects() const { return m_effects; } -size_t ShallowHash::operator()(const EffectAndImpl& e) const { return ShallowHashCombiner()(get_sorted_vector(e.get_effects())); } - -bool ShallowEqualTo::operator()(const EffectAndImpl& l, const EffectAndImpl& r) const -{ - if (&l != &r) - { - return (get_sorted_vector(l.get_effects()) == get_sorted_vector(r.get_effects())); - } - return true; -} - /* EffectNumeric */ EffectNumericImpl::EffectNumericImpl(size_t index, AssignOperatorEnum assign_operator, Function function, FunctionExpression function_expression) : Base(index), @@ -113,21 +88,6 @@ const Function& EffectNumericImpl::get_function() const { return m_function; } const FunctionExpression& EffectNumericImpl::get_function_expression() const { return m_function_expression; } -size_t ShallowHash::operator()(const EffectNumericImpl& e) const -{ - return ShallowHashCombiner()(e.get_assign_operator(), e.get_function(), e.get_function_expression()); -} - -bool ShallowEqualTo::operator()(const EffectNumericImpl& l, const EffectNumericImpl& r) const -{ - if (&l != &r) - { - return (l.get_assign_operator() == r.get_assign_operator()) && (l.get_function() == r.get_function()) - && (l.get_function_expression() == r.get_function_expression()); - } - return true; -} - /* ConditionalConditionalForall */ EffectConditionalForallImpl::EffectConditionalForallImpl(size_t index, ParameterList parameters, Effect effect) : Base(index), @@ -154,20 +114,6 @@ const ParameterList& EffectConditionalForallImpl::get_parameters() const { retur const Effect& EffectConditionalForallImpl::get_effect() const { return m_effect; } -size_t ShallowHash::operator()(const EffectConditionalForallImpl& e) const -{ - return ShallowHashCombiner()(e.get_effect(), get_sorted_vector(e.get_parameters())); -} - -bool ShallowEqualTo::operator()(const EffectConditionalForallImpl& l, const EffectConditionalForallImpl& r) const -{ - if (&l != &r) - { - return (l.get_effect() == r.get_effect()) && (get_sorted_vector(l.get_parameters()) == get_sorted_vector(r.get_parameters())); - } - return true; -} - /* EffectConditionalWhen */ EffectConditionalWhenImpl::EffectConditionalWhenImpl(size_t index, Condition condition, Effect effect) : Base(index), @@ -189,27 +135,4 @@ const Condition& EffectConditionalWhenImpl::get_condition() const { return m_con const Effect& EffectConditionalWhenImpl::get_effect() const { return m_effect; } -size_t ShallowHash::operator()(const EffectConditionalWhenImpl& e) const -{ - return ShallowHashCombiner()(e.get_condition(), e.get_effect()); -} - -bool ShallowEqualTo::operator()(const EffectConditionalWhenImpl& l, const EffectConditionalWhenImpl& r) const -{ - if (&l != &r) - { - return (l.get_condition() == r.get_condition()) && (l.get_effect() == r.get_effect()); - } - return true; -} - -/* EffectImpl */ - -size_t ShallowHash::operator()(const EffectImpl* e) const -{ - return std::visit([](const auto& arg) { return ShallowHash()(arg); }, *e); -} - -bool ShallowEqualTo::operator()(const EffectImpl* l, const EffectImpl* r) const { return ShallowEqualTo()(*l, *r); } - } diff --git a/src/pddl/function.cpp b/src/pddl/function.cpp index 728d345..b4815ef 100644 --- a/src/pddl/function.cpp +++ b/src/pddl/function.cpp @@ -20,8 +20,6 @@ #include "loki/details/pddl/function_skeleton.hpp" #include "loki/details/pddl/term.hpp" #include "loki/details/pddl/visitors.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" namespace loki { @@ -55,15 +53,4 @@ const FunctionSkeleton& FunctionImpl::get_function_skeleton() const { return m_f const TermList& FunctionImpl::get_terms() const { return m_terms; } -size_t ShallowHash::operator()(const FunctionImpl* e) const { return ShallowHashCombiner()(e->get_function_skeleton(), e->get_terms()); } - -bool ShallowEqualTo::operator()(const FunctionImpl* l, const FunctionImpl* r) const -{ - if (&l != &r) - { - return (l->get_function_skeleton() == r->get_function_skeleton()) && (l->get_terms() == r->get_terms()); - } - return true; -} - } diff --git a/src/pddl/function_expressions.cpp b/src/pddl/function_expressions.cpp index 5156d8a..65d148c 100644 --- a/src/pddl/function_expressions.cpp +++ b/src/pddl/function_expressions.cpp @@ -19,9 +19,6 @@ #include "loki/details/pddl/function.hpp" #include "loki/details/pddl/visitors.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" #include @@ -59,20 +56,6 @@ void FunctionExpressionNumberImpl::str_impl(std::ostream& out, const FormattingO double FunctionExpressionNumberImpl::get_number() const { return m_number; } -size_t ShallowHash::operator()(const FunctionExpressionNumberImpl& e) const -{ - return ShallowHashCombiner()(e.get_number()); -} - -bool ShallowEqualTo::operator()(const FunctionExpressionNumberImpl& l, const FunctionExpressionNumberImpl& r) const -{ - if (&l != &r) - { - return (l.get_number() == r.get_number()); - } - return true; -} - /* FunctionExpressionBinaryOperator */ FunctionExpressionBinaryOperatorImpl::FunctionExpressionBinaryOperatorImpl(size_t index, BinaryOperatorEnum binary_operator, @@ -100,22 +83,6 @@ const FunctionExpression& FunctionExpressionBinaryOperatorImpl::get_left_functio const FunctionExpression& FunctionExpressionBinaryOperatorImpl::get_right_function_expression() const { return m_right_function_expression; } -size_t ShallowHash::operator()(const FunctionExpressionBinaryOperatorImpl& e) const -{ - return ShallowHashCombiner()(e.get_binary_operator(), e.get_left_function_expression(), e.get_right_function_expression()); -} - -bool ShallowEqualTo::operator()(const FunctionExpressionBinaryOperatorImpl& l, - const FunctionExpressionBinaryOperatorImpl& r) const -{ - if (&l != &r) - { - return (l.get_binary_operator() == r.get_binary_operator()) && (l.get_left_function_expression() == r.get_left_function_expression()) - && (l.get_right_function_expression() == r.get_right_function_expression()); - } - return true; -} - /* FunctionExpressionMultiOperator */ FunctionExpressionMultiOperatorImpl::FunctionExpressionMultiOperatorImpl(size_t index, MultiOperatorEnum multi_operator, @@ -142,22 +109,6 @@ MultiOperatorEnum FunctionExpressionMultiOperatorImpl::get_multi_operator() cons const FunctionExpressionList& FunctionExpressionMultiOperatorImpl::get_function_expressions() const { return m_function_expressions; } -size_t ShallowHash::operator()(const FunctionExpressionMultiOperatorImpl& e) const -{ - return ShallowHashCombiner()(e.get_multi_operator(), get_sorted_vector(e.get_function_expressions())); -} - -bool ShallowEqualTo::operator()(const FunctionExpressionMultiOperatorImpl& l, - const FunctionExpressionMultiOperatorImpl& r) const -{ - if (&l != &r) - { - return (l.get_multi_operator() == r.get_multi_operator()) - && (get_sorted_vector(l.get_function_expressions()) == get_sorted_vector(r.get_function_expressions())); - } - return true; -} - /* FunctionExpressionMinus */ FunctionExpressionMinusImpl::FunctionExpressionMinusImpl(size_t index, FunctionExpression function_expression) : Base(index), @@ -174,20 +125,6 @@ void FunctionExpressionMinusImpl::str_impl(std::ostream& out, const FormattingOp const FunctionExpression& FunctionExpressionMinusImpl::get_function_expression() const { return m_function_expression; } -size_t ShallowHash::operator()(const FunctionExpressionMinusImpl& e) const -{ - return ShallowHashCombiner()(e.get_function_expression()); -} - -bool ShallowEqualTo::operator()(const FunctionExpressionMinusImpl& l, const FunctionExpressionMinusImpl& r) const -{ - if (&l != &r) - { - return (l.get_function_expression() == r.get_function_expression()); - } - return true; -} - /* FunctionExpressionFunction */ FunctionExpressionFunctionImpl::FunctionExpressionFunctionImpl(size_t index, Function function) : Base(index), m_function(std::move(function)) {} @@ -195,30 +132,4 @@ void FunctionExpressionFunctionImpl::str_impl(std::ostream& out, const Formattin const Function& FunctionExpressionFunctionImpl::get_function() const { return m_function; } -size_t ShallowHash::operator()(const FunctionExpressionFunctionImpl& e) const -{ - return ShallowHashCombiner()(e.get_function()); -} - -bool ShallowEqualTo::operator()(const FunctionExpressionFunctionImpl& l, const FunctionExpressionFunctionImpl& r) const -{ - if (&l != &r) - { - return (l.get_function() == r.get_function()); - } - return true; -} - -/* FunctionExpressionImpl */ - -size_t ShallowHash::operator()(const FunctionExpressionImpl* e) const -{ - return std::visit([](const auto& arg) { return ShallowHash()(arg); }, *e); -} - -bool ShallowEqualTo::operator()(const FunctionExpressionImpl* l, const FunctionExpressionImpl* r) const -{ - return ShallowEqualTo()(*l, *r); -} - } diff --git a/src/pddl/function_skeleton.cpp b/src/pddl/function_skeleton.cpp index 76ddbd9..bd72343 100644 --- a/src/pddl/function_skeleton.cpp +++ b/src/pddl/function_skeleton.cpp @@ -18,9 +18,6 @@ #include "loki/details/pddl/function_skeleton.hpp" #include "loki/details/pddl/parameter.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" namespace loki { @@ -49,19 +46,4 @@ const ParameterList& FunctionSkeletonImpl::get_parameters() const { return m_par const Type& FunctionSkeletonImpl::get_type() const { return m_type; } -size_t ShallowHash::operator()(const FunctionSkeletonImpl* e) const -{ - return ShallowHashCombiner()(e->get_name(), e->get_type(), get_sorted_vector(e->get_parameters())); -} - -bool ShallowEqualTo::operator()(const FunctionSkeletonImpl* l, const FunctionSkeletonImpl* r) const -{ - if (&l != &r) - { - return (l->get_name() == r->get_name()) && (l->get_type() == r->get_type()) - && (get_sorted_vector(l->get_parameters()) == get_sorted_vector(r->get_parameters())); - } - return true; -} - } diff --git a/src/pddl/literal.cpp b/src/pddl/literal.cpp index ab4ef08..72c5d75 100644 --- a/src/pddl/literal.cpp +++ b/src/pddl/literal.cpp @@ -18,9 +18,6 @@ #include "loki/details/pddl/literal.hpp" #include "loki/details/pddl/atom.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" namespace loki { @@ -44,15 +41,4 @@ bool LiteralImpl::is_negated() const { return m_is_negated; } const Atom& LiteralImpl::get_atom() const { return m_atom; } -size_t ShallowHash::operator()(const LiteralImpl* e) const { return ShallowHashCombiner()(e->is_negated(), e->get_atom()); } - -bool ShallowEqualTo::operator()(const LiteralImpl* l, const LiteralImpl* r) const -{ - if (&l != &r) - { - return (l->is_negated() == r->is_negated()) && (l->get_atom() == r->get_atom()); - } - return true; -} - } diff --git a/src/pddl/metric.cpp b/src/pddl/metric.cpp index 7e89ea3..ba6f1cc 100644 --- a/src/pddl/metric.cpp +++ b/src/pddl/metric.cpp @@ -19,9 +19,6 @@ #include "loki/details/pddl/function_expressions.hpp" #include "loki/details/pddl/visitors.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" #include @@ -58,18 +55,4 @@ OptimizationMetricEnum OptimizationMetricImpl::get_optimization_metric() const { const FunctionExpression& OptimizationMetricImpl::get_function_expression() const { return m_function_expression; } -size_t ShallowHash::operator()(const OptimizationMetricImpl* e) const -{ - return ShallowHashCombiner()(e->get_optimization_metric(), e->get_function_expression()); -} - -bool ShallowEqualTo::operator()(const OptimizationMetricImpl* l, const OptimizationMetricImpl* r) const -{ - if (&l != &r) - { - return (l->get_optimization_metric() == r->get_optimization_metric()) && (l->get_function_expression() == r->get_function_expression()); - } - return true; -} - } diff --git a/src/pddl/numeric_fluent.cpp b/src/pddl/numeric_fluent.cpp index 058f986..3f2756c 100644 --- a/src/pddl/numeric_fluent.cpp +++ b/src/pddl/numeric_fluent.cpp @@ -18,8 +18,6 @@ #include "loki/details/pddl/numeric_fluent.hpp" #include "loki/details/pddl/function.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" namespace loki { @@ -36,15 +34,4 @@ const Function& NumericFluentImpl::get_function() const { return m_function; } double NumericFluentImpl::get_number() const { return m_number; } -size_t ShallowHash::operator()(const NumericFluentImpl* e) const { return ShallowHashCombiner()(e->get_number(), e->get_function()); } - -bool ShallowEqualTo::operator()(const NumericFluentImpl* l, const NumericFluentImpl* r) const -{ - if (&l != &r) - { - return (l->get_number() == r->get_number()) && (l->get_function() == r->get_function()); - } - return true; -} - } diff --git a/src/pddl/object.cpp b/src/pddl/object.cpp index 2997c7a..5d9f0dd 100644 --- a/src/pddl/object.cpp +++ b/src/pddl/object.cpp @@ -18,9 +18,6 @@ #include "loki/details/pddl/object.hpp" #include "loki/details/pddl/type.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" namespace loki { @@ -54,15 +51,4 @@ const std::string& ObjectImpl::get_name() const { return m_name; } const TypeList& ObjectImpl::get_bases() const { return m_types; } -size_t ShallowHash::operator()(const ObjectImpl* e) const { return ShallowHashCombiner()(e->get_name(), get_sorted_vector(e->get_bases())); } - -bool ShallowEqualTo::operator()(const ObjectImpl* l, const ObjectImpl* r) const -{ - if (&l != &r) - { - return (l->get_name() == r->get_name()) && (get_sorted_vector(l->get_bases()) == get_sorted_vector(r->get_bases())); - } - return true; -} - } diff --git a/src/pddl/parameter.cpp b/src/pddl/parameter.cpp index d06c68c..f79e176 100644 --- a/src/pddl/parameter.cpp +++ b/src/pddl/parameter.cpp @@ -19,9 +19,6 @@ #include "loki/details/pddl/type.hpp" #include "loki/details/pddl/variable.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" #include @@ -57,20 +54,6 @@ const Variable& ParameterImpl::get_variable() const { return m_variable; } const TypeList& ParameterImpl::get_bases() const { return m_types; } -size_t ShallowHash::operator()(const ParameterImpl* e) const -{ - return ShallowHashCombiner()(e->get_variable(), get_sorted_vector(e->get_bases())); -} - -bool ShallowEqualTo::operator()(const ParameterImpl* l, const ParameterImpl* r) const -{ - if (&l != &r) - { - return (l->get_variable() == r->get_variable()) && (get_sorted_vector(l->get_bases()) == get_sorted_vector(r->get_bases())); - } - return true; -} - bool is_specialized_parameter(const Parameter& specialized_parameter, const Parameter& generalized_parameter) { for (const auto& type : specialized_parameter->get_bases()) diff --git a/src/pddl/predicate.cpp b/src/pddl/predicate.cpp index 22c664c..2f77c45 100644 --- a/src/pddl/predicate.cpp +++ b/src/pddl/predicate.cpp @@ -20,9 +20,6 @@ #include "loki/details/pddl/parameter.hpp" #include "loki/details/pddl/type.hpp" #include "loki/details/pddl/variable.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" #include @@ -50,18 +47,4 @@ const std::string& PredicateImpl::get_name() const { return m_name; } const ParameterList& PredicateImpl::get_parameters() const { return m_parameters; } -size_t ShallowHash::operator()(const PredicateImpl* e) const -{ - return ShallowHashCombiner()(e->get_name(), get_sorted_vector(e->get_parameters())); -} - -bool ShallowEqualTo::operator()(const PredicateImpl* l, const PredicateImpl* r) const -{ - if (&l != &r) - { - return (l->get_name() == r->get_name()) && (get_sorted_vector(l->get_parameters()) == get_sorted_vector(r->get_parameters())); - } - return true; -} - } diff --git a/src/pddl/problem.cpp b/src/pddl/problem.cpp index 72de3e5..d971b1f 100644 --- a/src/pddl/problem.cpp +++ b/src/pddl/problem.cpp @@ -28,7 +28,6 @@ #include "loki/details/pddl/requirements.hpp" #include "loki/details/pddl/type.hpp" #include "loki/details/pddl/visitors.hpp" -#include "loki/details/utils/collections.hpp" #include "loki/details/utils/equal_to.hpp" #include "loki/details/utils/hash.hpp" @@ -80,7 +79,7 @@ void ProblemImpl::str_impl(std::ostream& out, const FormattingOptions& options) if (!m_objects.empty()) { out << string(nested_options.indent, ' ') << "(:objects "; - std::unordered_map> objects_by_types; + std::unordered_map> objects_by_types; for (const auto& object : m_objects) { objects_by_types[object->get_bases()].push_back(object); @@ -201,30 +200,4 @@ const std::optional& ProblemImpl::get_optimization_metric() const AxiomList& ProblemImpl::get_axioms() const { return m_axioms; } -size_t ShallowHash::operator()(const ProblemImpl* e) const -{ - return ShallowHashCombiner()(e->get_name(), - e->get_domain(), - get_sorted_vector(e->get_objects()), - get_sorted_vector(e->get_derived_predicates()), - get_sorted_vector(e->get_initial_literals()), - get_sorted_vector(e->get_numeric_fluents()), - e->get_goal_condition(), - e->get_optimization_metric()); -} - -bool ShallowEqualTo::operator()(const ProblemImpl* l, const ProblemImpl* r) const -{ - if (&l != &r) - { - return (l->get_name() == r->get_name()) && (l->get_domain() == r->get_domain()) - && (get_sorted_vector(l->get_objects()) == get_sorted_vector(r->get_objects())) - && (get_sorted_vector(l->get_derived_predicates()) == get_sorted_vector(r->get_derived_predicates())) - && (get_sorted_vector(l->get_initial_literals()) == get_sorted_vector(r->get_initial_literals())) - && (get_sorted_vector(l->get_numeric_fluents()) == get_sorted_vector(r->get_numeric_fluents())) - && (l->get_goal_condition() == r->get_goal_condition()) && (l->get_optimization_metric() == r->get_optimization_metric()); - } - return true; -} - } diff --git a/src/pddl/requirements.cpp b/src/pddl/requirements.cpp index 9f94b26..1c3c82f 100644 --- a/src/pddl/requirements.cpp +++ b/src/pddl/requirements.cpp @@ -17,9 +17,6 @@ #include "loki/details/pddl/requirements.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" - #include namespace loki @@ -71,15 +68,4 @@ bool RequirementsImpl::test(RequirementEnum requirement) const { return m_requir const RequirementEnumSet& RequirementsImpl::get_requirements() const { return m_requirements; } -size_t ShallowHash::operator()(const RequirementsImpl* e) const { return ShallowHashCombiner()(e->get_requirements()); } - -bool ShallowEqualTo::operator()(const RequirementsImpl* l, const RequirementsImpl* r) const -{ - if (&l != &r) - { - return (l->get_requirements() == r->get_requirements()); - } - return true; -} - } diff --git a/src/pddl/term.cpp b/src/pddl/term.cpp index 577a396..9275f7c 100644 --- a/src/pddl/term.cpp +++ b/src/pddl/term.cpp @@ -19,9 +19,6 @@ #include "loki/details/pddl/object.hpp" #include "loki/details/pddl/variable.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" namespace loki { @@ -33,17 +30,6 @@ void TermObjectImpl::str_impl(std::ostream& out, const FormattingOptions& /*opti const Object& TermObjectImpl::get_object() const { return m_object; } -size_t ShallowHash::operator()(const TermObjectImpl& e) const { return ShallowHashCombiner()(e.get_object()); } - -bool ShallowEqualTo::operator()(const TermObjectImpl& l, const TermObjectImpl& r) const -{ - if (&l != &r) - { - return (l.get_object() == r.get_object()); - } - return true; -} - /* TermVariableImpl */ TermVariableImpl::TermVariableImpl(size_t index, Variable variable) : Base(index), m_variable(std::move(variable)) {} @@ -51,24 +37,4 @@ void TermVariableImpl::str_impl(std::ostream& out, const FormattingOptions& /*op const Variable& TermVariableImpl::get_variable() const { return m_variable; } -size_t ShallowHash::operator()(const TermVariableImpl& e) const { return ShallowHashCombiner()(e.get_variable()); } - -bool ShallowEqualTo::operator()(const TermVariableImpl& l, const TermVariableImpl& r) const -{ - if (&l != &r) - { - return (l.get_variable() == r.get_variable()); - } - return true; -} - -/* TermImpl */ - -size_t ShallowHash::operator()(const TermImpl* e) const -{ - return std::visit([](const auto& arg) { return ShallowHash()(arg); }, *e); -} - -bool ShallowEqualTo::operator()(const TermImpl* l, const TermImpl* r) const { return ShallowEqualTo()(*l, *r); } - } diff --git a/src/pddl/type.cpp b/src/pddl/type.cpp index d769117..dc5bc83 100644 --- a/src/pddl/type.cpp +++ b/src/pddl/type.cpp @@ -17,10 +17,6 @@ #include "loki/details/pddl/type.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" - namespace loki { TypeImpl::TypeImpl(size_t index, std::string name, TypeList bases) : Base(index), m_name(std::move(name)), m_bases(std::move(bases)) {} @@ -53,17 +49,6 @@ const std::string& TypeImpl::get_name() const { return m_name; } const TypeList& TypeImpl::get_bases() const { return m_bases; } -size_t ShallowHash::operator()(const TypeImpl* e) const { return ShallowHashCombiner()(e->get_name(), get_sorted_vector(e->get_bases())); } - -bool ShallowEqualTo::operator()(const TypeImpl* l, const TypeImpl* r) const -{ - if (&l != &r) - { - return (l->get_name() == r->get_name()) && (get_sorted_vector(l->get_bases()) == get_sorted_vector(r->get_bases())); - } - return true; -} - static void collect_types_from_hierarchy_recursively(const TypeList& types, TypeSet& ref_result) { for (const auto& type : types) diff --git a/src/pddl/variable.cpp b/src/pddl/variable.cpp index 88d2977..4bd61a1 100644 --- a/src/pddl/variable.cpp +++ b/src/pddl/variable.cpp @@ -22,9 +22,6 @@ #include "loki/details/pddl/literal.hpp" #include "loki/details/pddl/parameter.hpp" #include "loki/details/pddl/term.hpp" -#include "loki/details/utils/collections.hpp" -#include "loki/details/utils/equal_to.hpp" -#include "loki/details/utils/hash.hpp" namespace loki { @@ -34,17 +31,6 @@ void VariableImpl::str_impl(std::ostream& out, const FormattingOptions& /*option const std::string& VariableImpl::get_name() const { return m_name; } -size_t ShallowHash::operator()(const VariableImpl* e) const { return ShallowHashCombiner()(e->get_name()); } - -bool ShallowEqualTo::operator()(const VariableImpl* l, const VariableImpl* r) const -{ - if (&l != &r) - { - return (l->get_name() == r->get_name()); - } - return true; -} - static void collect_free_variables_recursively(const loki::ConditionImpl& condition, VariableSet& ref_quantified_variables, VariableSet& ref_free_variables) { if (const auto condition_literal = std::get_if(&condition)) diff --git a/src/utils/equal_to.cpp b/src/utils/equal_to.cpp new file mode 100644 index 0000000..cf536ba --- /dev/null +++ b/src/utils/equal_to.cpp @@ -0,0 +1,396 @@ +/* + * Copyright (C) 2023 Dominik Drexler and Simon Stahlberg + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "loki/details/utils/equal_to.hpp" + +#include "loki/details/pddl/action.hpp" +#include "loki/details/pddl/atom.hpp" +#include "loki/details/pddl/axiom.hpp" +#include "loki/details/pddl/conditions.hpp" +#include "loki/details/pddl/declarations.hpp" +#include "loki/details/pddl/domain.hpp" +#include "loki/details/pddl/effects.hpp" +#include "loki/details/pddl/function.hpp" +#include "loki/details/pddl/function_expressions.hpp" +#include "loki/details/pddl/function_skeleton.hpp" +#include "loki/details/pddl/literal.hpp" +#include "loki/details/pddl/metric.hpp" +#include "loki/details/pddl/numeric_fluent.hpp" +#include "loki/details/pddl/object.hpp" +#include "loki/details/pddl/parameter.hpp" +#include "loki/details/pddl/position.hpp" +#include "loki/details/pddl/predicate.hpp" +#include "loki/details/pddl/problem.hpp" +#include "loki/details/pddl/requirements.hpp" +#include "loki/details/pddl/term.hpp" +#include "loki/details/pddl/type.hpp" +#include "loki/details/pddl/variable.hpp" +#include "loki/details/utils/collections.hpp" + +namespace loki +{ +bool EqualTo::operator()(const ActionImpl* l, const ActionImpl* r) const +{ + if (&l != &r) + { + return (l->get_name() == r->get_name()) && (get_sorted_vector(l->get_parameters()) == get_sorted_vector(r->get_parameters())) + && (l->get_condition() == r->get_condition()) && (l->get_effect() == r->get_effect()); + } + return true; +} + +bool EqualTo::operator()(const AtomImpl* l, const AtomImpl* r) const +{ + if (&l != &r) + { + return (l->get_predicate() == r->get_predicate()) && (l->get_terms() == r->get_terms()); + } + return true; +} + +bool EqualTo::operator()(const AxiomImpl* l, const AxiomImpl* r) const +{ + if (&l != &r) + { + return (l->get_derived_predicate_name() == r->get_derived_predicate_name()) + && (get_sorted_vector(l->get_parameters()) == get_sorted_vector(r->get_parameters())) && (l->get_condition() == r->get_condition()); + } + return true; +} + +bool EqualTo::operator()(const ConditionLiteralImpl& l, const ConditionLiteralImpl& r) const +{ + if (&l != &r) + { + return (l.get_literal() == r.get_literal()); + } + return true; +} + +bool EqualTo::operator()(const ConditionAndImpl& l, const ConditionAndImpl& r) const +{ + if (&l != &r) + { + return (get_sorted_vector(l.get_conditions()) == get_sorted_vector(r.get_conditions())); + } + return true; +} + +bool EqualTo::operator()(const ConditionOrImpl& l, const ConditionOrImpl& r) const +{ + if (&l != &r) + { + return (get_sorted_vector(l.get_conditions()) == get_sorted_vector(r.get_conditions())); + } + return true; +} + +bool EqualTo::operator()(const ConditionNotImpl& l, const ConditionNotImpl& r) const +{ + if (&l != &r) + { + return (l.get_condition() == r.get_condition()); + } + return true; +} + +bool EqualTo::operator()(const ConditionImplyImpl& l, const ConditionImplyImpl& r) const +{ + if (&l != &r) + { + return (l.get_condition_left() == r.get_condition_left()) && (l.get_condition_left() == r.get_condition_left()); + } + return true; +} + +bool EqualTo::operator()(const ConditionExistsImpl& l, const ConditionExistsImpl& r) const +{ + if (&l != &r) + { + return (l.get_condition() == r.get_condition()) && (get_sorted_vector(l.get_parameters()) == get_sorted_vector(r.get_parameters())); + } + return true; +} + +bool EqualTo::operator()(const ConditionForallImpl& l, const ConditionForallImpl& r) const +{ + if (&l != &r) + { + return (l.get_condition() == r.get_condition()) && (get_sorted_vector(l.get_parameters()) == get_sorted_vector(r.get_parameters())); + } + return true; +} + +bool EqualTo::operator()(const ConditionImpl* l, const ConditionImpl* r) const { return EqualTo()(*l, *r); } + +bool EqualTo::operator()(const DomainImpl* l, const DomainImpl* r) const +{ + if (&l != &r) + { + return (l->get_name() == r->get_name()) && (l->get_requirements() == r->get_requirements()) + && (get_sorted_vector(l->get_types()) == get_sorted_vector(r->get_types())) + && (get_sorted_vector(l->get_constants()) == get_sorted_vector(r->get_constants())) + && (get_sorted_vector(l->get_predicates()) == get_sorted_vector(r->get_predicates())) + && (get_sorted_vector(l->get_functions()) == get_sorted_vector(r->get_functions())) + && (get_sorted_vector(l->get_actions()) == get_sorted_vector(r->get_actions())) + && (get_sorted_vector(l->get_axioms()) == get_sorted_vector(r->get_axioms())); + } + return true; +} + +bool EqualTo::operator()(const EffectLiteralImpl& l, const EffectLiteralImpl& r) const +{ + if (&l != &r) + { + return (l.get_literal() == r.get_literal()); + } + return true; +} + +bool EqualTo::operator()(const EffectAndImpl& l, const EffectAndImpl& r) const +{ + if (&l != &r) + { + return (get_sorted_vector(l.get_effects()) == get_sorted_vector(r.get_effects())); + } + return true; +} + +bool EqualTo::operator()(const EffectNumericImpl& l, const EffectNumericImpl& r) const +{ + if (&l != &r) + { + return (l.get_assign_operator() == r.get_assign_operator()) && (l.get_function() == r.get_function()) + && (l.get_function_expression() == r.get_function_expression()); + } + return true; +} + +bool EqualTo::operator()(const EffectConditionalForallImpl& l, const EffectConditionalForallImpl& r) const +{ + if (&l != &r) + { + return (l.get_effect() == r.get_effect()) && (get_sorted_vector(l.get_parameters()) == get_sorted_vector(r.get_parameters())); + } + return true; +} + +bool EqualTo::operator()(const EffectConditionalWhenImpl& l, const EffectConditionalWhenImpl& r) const +{ + if (&l != &r) + { + return (l.get_condition() == r.get_condition()) && (l.get_effect() == r.get_effect()); + } + return true; +} + +bool EqualTo::operator()(const EffectImpl* l, const EffectImpl* r) const { return EqualTo()(*l, *r); } + +bool EqualTo::operator()(const FunctionExpressionNumberImpl& l, const FunctionExpressionNumberImpl& r) const +{ + if (&l != &r) + { + return (l.get_number() == r.get_number()); + } + return true; +} + +bool EqualTo::operator()(const FunctionExpressionBinaryOperatorImpl& l, + const FunctionExpressionBinaryOperatorImpl& r) const +{ + if (&l != &r) + { + return (l.get_binary_operator() == r.get_binary_operator()) && (l.get_left_function_expression() == r.get_left_function_expression()) + && (l.get_right_function_expression() == r.get_right_function_expression()); + } + return true; +} + +bool EqualTo::operator()(const FunctionExpressionMultiOperatorImpl& l, + const FunctionExpressionMultiOperatorImpl& r) const +{ + if (&l != &r) + { + return (l.get_multi_operator() == r.get_multi_operator()) + && (get_sorted_vector(l.get_function_expressions()) == get_sorted_vector(r.get_function_expressions())); + } + return true; +} + +bool EqualTo::operator()(const FunctionExpressionMinusImpl& l, const FunctionExpressionMinusImpl& r) const +{ + if (&l != &r) + { + return (l.get_function_expression() == r.get_function_expression()); + } + return true; +} + +bool EqualTo::operator()(const FunctionExpressionFunctionImpl& l, const FunctionExpressionFunctionImpl& r) const +{ + if (&l != &r) + { + return (l.get_function() == r.get_function()); + } + return true; +} + +bool EqualTo::operator()(const FunctionExpressionImpl* l, const FunctionExpressionImpl* r) const +{ + return EqualTo()(*l, *r); +} + +template<> +struct EqualTo +{ + bool operator()(const FunctionSkeletonImpl* l, const FunctionSkeletonImpl* r) const; +}; + +bool EqualTo::operator()(const FunctionSkeletonImpl* l, const FunctionSkeletonImpl* r) const +{ + if (&l != &r) + { + return (l->get_name() == r->get_name()) && (l->get_type() == r->get_type()) + && (get_sorted_vector(l->get_parameters()) == get_sorted_vector(r->get_parameters())); + } + return true; +} + +bool EqualTo::operator()(const FunctionImpl* l, const FunctionImpl* r) const +{ + if (&l != &r) + { + return (l->get_function_skeleton() == r->get_function_skeleton()) && (l->get_terms() == r->get_terms()); + } + return true; +} + +bool EqualTo::operator()(const LiteralImpl* l, const LiteralImpl* r) const +{ + if (&l != &r) + { + return (l->is_negated() == r->is_negated()) && (l->get_atom() == r->get_atom()); + } + return true; +} + +bool EqualTo::operator()(const OptimizationMetricImpl* l, const OptimizationMetricImpl* r) const +{ + if (&l != &r) + { + return (l->get_optimization_metric() == r->get_optimization_metric()) && (l->get_function_expression() == r->get_function_expression()); + } + return true; +} + +bool EqualTo::operator()(const NumericFluentImpl* l, const NumericFluentImpl* r) const +{ + if (&l != &r) + { + return (l->get_number() == r->get_number()) && (l->get_function() == r->get_function()); + } + return true; +} + +bool EqualTo::operator()(const ObjectImpl* l, const ObjectImpl* r) const +{ + if (&l != &r) + { + return (l->get_name() == r->get_name()) && (get_sorted_vector(l->get_bases()) == get_sorted_vector(r->get_bases())); + } + return true; +} + +bool EqualTo::operator()(const ParameterImpl* l, const ParameterImpl* r) const +{ + if (&l != &r) + { + return (l->get_variable() == r->get_variable()) && (get_sorted_vector(l->get_bases()) == get_sorted_vector(r->get_bases())); + } + return true; +} + +bool EqualTo::operator()(const PredicateImpl* l, const PredicateImpl* r) const +{ + if (&l != &r) + { + return (l->get_name() == r->get_name()) && (get_sorted_vector(l->get_parameters()) == get_sorted_vector(r->get_parameters())); + } + return true; +} + +bool EqualTo::operator()(const ProblemImpl* l, const ProblemImpl* r) const +{ + if (&l != &r) + { + return (l->get_name() == r->get_name()) && (l->get_domain() == r->get_domain()) + && (get_sorted_vector(l->get_objects()) == get_sorted_vector(r->get_objects())) + && (get_sorted_vector(l->get_derived_predicates()) == get_sorted_vector(r->get_derived_predicates())) + && (get_sorted_vector(l->get_initial_literals()) == get_sorted_vector(r->get_initial_literals())) + && (get_sorted_vector(l->get_numeric_fluents()) == get_sorted_vector(r->get_numeric_fluents())) + && (l->get_goal_condition() == r->get_goal_condition()) && (l->get_optimization_metric() == r->get_optimization_metric()); + } + return true; +} + +bool EqualTo::operator()(const RequirementsImpl* l, const RequirementsImpl* r) const +{ + if (&l != &r) + { + return (l->get_requirements() == r->get_requirements()); + } + return true; +} + +bool EqualTo::operator()(const TermObjectImpl& l, const TermObjectImpl& r) const +{ + if (&l != &r) + { + return (l.get_object() == r.get_object()); + } + return true; +} + +bool EqualTo::operator()(const TermVariableImpl& l, const TermVariableImpl& r) const +{ + if (&l != &r) + { + return (l.get_variable() == r.get_variable()); + } + return true; +} + +bool EqualTo::operator()(const TermImpl* l, const TermImpl* r) const { return EqualTo()(*l, *r); } + +bool EqualTo::operator()(const TypeImpl* l, const TypeImpl* r) const +{ + if (&l != &r) + { + return (l->get_name() == r->get_name()) && (get_sorted_vector(l->get_bases()) == get_sorted_vector(r->get_bases())); + } + return true; +} + +bool EqualTo::operator()(const VariableImpl* l, const VariableImpl* r) const +{ + if (&l != &r) + { + return (l->get_name() == r->get_name()); + } + return true; +} +} diff --git a/src/utils/hash.cpp b/src/utils/hash.cpp new file mode 100644 index 0000000..638e134 --- /dev/null +++ b/src/utils/hash.cpp @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2023 Dominik Drexler and Simon Stahlberg + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "loki/details/utils/hash.hpp" + +#include "loki/details/pddl/action.hpp" +#include "loki/details/pddl/atom.hpp" +#include "loki/details/pddl/axiom.hpp" +#include "loki/details/pddl/conditions.hpp" +#include "loki/details/pddl/declarations.hpp" +#include "loki/details/pddl/domain.hpp" +#include "loki/details/pddl/effects.hpp" +#include "loki/details/pddl/function.hpp" +#include "loki/details/pddl/function_expressions.hpp" +#include "loki/details/pddl/function_skeleton.hpp" +#include "loki/details/pddl/literal.hpp" +#include "loki/details/pddl/metric.hpp" +#include "loki/details/pddl/numeric_fluent.hpp" +#include "loki/details/pddl/object.hpp" +#include "loki/details/pddl/parameter.hpp" +#include "loki/details/pddl/position.hpp" +#include "loki/details/pddl/predicate.hpp" +#include "loki/details/pddl/problem.hpp" +#include "loki/details/pddl/requirements.hpp" +#include "loki/details/pddl/term.hpp" +#include "loki/details/pddl/type.hpp" +#include "loki/details/pddl/variable.hpp" +#include "loki/details/utils/collections.hpp" + +namespace loki +{ +size_t Hasher::operator()(const ActionImpl* e) const +{ + return HashCombiner()(e->get_name(), get_sorted_vector(e->get_parameters()), e->get_condition(), e->get_effect()); +} + +size_t Hasher::operator()(const AtomImpl* e) const { return HashCombiner()(e->get_predicate(), e->get_terms()); } + +size_t Hasher::operator()(const AxiomImpl* e) const +{ + return HashCombiner()(e->get_derived_predicate_name(), get_sorted_vector(e->get_parameters()), e->get_condition()); +} + +size_t Hasher::operator()(const ConditionLiteralImpl& e) const { return HashCombiner()(e.get_literal()); } + +size_t Hasher::operator()(const ConditionAndImpl& e) const { return HashCombiner()(get_sorted_vector(e.get_conditions())); } + +size_t Hasher::operator()(const ConditionOrImpl& e) const { return HashCombiner()(get_sorted_vector(e.get_conditions())); } + +size_t Hasher::operator()(const ConditionNotImpl& e) const { return HashCombiner()(e.get_condition()); } + +size_t Hasher::operator()(const ConditionImplyImpl& e) const +{ + return HashCombiner()(e.get_condition_left(), e.get_condition_right()); +} + +size_t Hasher::operator()(const ConditionExistsImpl& e) const +{ + return HashCombiner()(get_sorted_vector(e.get_parameters()), e.get_condition()); +} + +size_t Hasher::operator()(const ConditionForallImpl& e) const +{ + return HashCombiner()(get_sorted_vector(e.get_parameters()), e.get_condition()); +} + +size_t Hasher::operator()(const ConditionImpl* e) const +{ + return std::visit([](const auto& arg) { return Hasher()(arg); }, *e); +} + +size_t Hasher::operator()(const DomainImpl* e) const +{ + return HashCombiner()(e->get_name(), + e->get_requirements(), + get_sorted_vector(e->get_types()), + get_sorted_vector(e->get_constants()), + get_sorted_vector(e->get_predicates()), + get_sorted_vector(e->get_functions()), + get_sorted_vector(e->get_actions()), + get_sorted_vector(e->get_axioms())); +} + +size_t Hasher::operator()(const EffectLiteralImpl& e) const { return HashCombiner()(e.get_literal()); } + +size_t Hasher::operator()(const EffectAndImpl& e) const { return HashCombiner()(get_sorted_vector(e.get_effects())); } + +size_t Hasher::operator()(const EffectNumericImpl& e) const +{ + return HashCombiner()(e.get_assign_operator(), e.get_function(), e.get_function_expression()); +} + +size_t Hasher::operator()(const EffectConditionalForallImpl& e) const +{ + return HashCombiner()(e.get_effect(), get_sorted_vector(e.get_parameters())); +} + +size_t Hasher::operator()(const EffectConditionalWhenImpl& e) const +{ + return HashCombiner()(e.get_condition(), e.get_effect()); +} + +size_t Hasher::operator()(const EffectImpl* e) const +{ + return std::visit([](const auto& arg) { return Hasher()(arg); }, *e); +} + +size_t Hasher::operator()(const FunctionExpressionNumberImpl& e) const { return HashCombiner()(e.get_number()); } + +size_t Hasher::operator()(const FunctionExpressionBinaryOperatorImpl& e) const +{ + return HashCombiner()(e.get_binary_operator(), e.get_left_function_expression(), e.get_right_function_expression()); +} + +size_t Hasher::operator()(const FunctionExpressionMultiOperatorImpl& e) const +{ + return HashCombiner()(e.get_multi_operator(), get_sorted_vector(e.get_function_expressions())); +} + +size_t Hasher::operator()(const FunctionExpressionMinusImpl& e) const +{ + return HashCombiner()(e.get_function_expression()); +} + +size_t Hasher::operator()(const FunctionExpressionFunctionImpl& e) const { return HashCombiner()(e.get_function()); } + +size_t Hasher::operator()(const FunctionExpressionImpl* e) const +{ + return std::visit([](const auto& arg) { return Hasher()(arg); }, *e); +} + +size_t Hasher::operator()(const FunctionSkeletonImpl* e) const +{ + return HashCombiner()(e->get_name(), e->get_type(), get_sorted_vector(e->get_parameters())); +} + +size_t Hasher::operator()(const FunctionImpl* e) const { return HashCombiner()(e->get_function_skeleton(), e->get_terms()); } + +size_t Hasher::operator()(const LiteralImpl* e) const { return HashCombiner()(e->is_negated(), e->get_atom()); } + +size_t Hasher::operator()(const OptimizationMetricImpl* e) const +{ + return HashCombiner()(e->get_optimization_metric(), e->get_function_expression()); +} + +size_t Hasher::operator()(const NumericFluentImpl* e) const { return HashCombiner()(e->get_number(), e->get_function()); } + +size_t Hasher::operator()(const ObjectImpl* e) const { return HashCombiner()(e->get_name(), get_sorted_vector(e->get_bases())); } + +size_t Hasher::operator()(const ParameterImpl* e) const { return HashCombiner()(e->get_variable(), get_sorted_vector(e->get_bases())); } + +size_t Hasher::operator()(const PredicateImpl* e) const { return HashCombiner()(e->get_name(), get_sorted_vector(e->get_parameters())); } + +size_t Hasher::operator()(const ProblemImpl* e) const +{ + return HashCombiner()(e->get_name(), + e->get_domain(), + get_sorted_vector(e->get_objects()), + get_sorted_vector(e->get_derived_predicates()), + get_sorted_vector(e->get_initial_literals()), + get_sorted_vector(e->get_numeric_fluents()), + e->get_goal_condition(), + e->get_optimization_metric()); +} + +size_t Hasher::operator()(const RequirementsImpl* e) const { return HashCombiner()(e->get_requirements()); } + +size_t Hasher::operator()(const TermObjectImpl& e) const { return HashCombiner()(e.get_object()); } + +size_t Hasher::operator()(const TermVariableImpl& e) const { return HashCombiner()(e.get_variable()); } + +size_t Hasher::operator()(const TermImpl* e) const +{ + return std::visit([](const auto& arg) { return Hasher()(arg); }, *e); +} + +size_t Hasher::operator()(const TypeImpl* e) const { return HashCombiner()(e->get_name(), get_sorted_vector(e->get_bases())); } + +size_t Hasher::operator()(const VariableImpl* e) const { return HashCombiner()(e->get_name()); } +} diff --git a/tests/unit/utils/value_type_factory.cpp b/tests/unit/utils/value_type_factory.cpp index f4cc9ed..4bab0fb 100644 --- a/tests/unit/utils/value_type_factory.cpp +++ b/tests/unit/utils/value_type_factory.cpp @@ -86,16 +86,16 @@ TEST(LokiTests, UtilsUniqueFactoryTest) const auto object_0_1 = factory.get_or_create("object_0", TypeList()); EXPECT_EQ(factory.size(), 1); EXPECT_EQ(object_0_0, object_0_1); - EXPECT_EQ(ShallowHash()(object_0_0), ShallowHash()(object_0_1)); - EXPECT_TRUE(ShallowEqualTo()(object_0_0, object_0_1)); + EXPECT_EQ(Hasher()(object_0_0), Hasher()(object_0_1)); + EXPECT_TRUE(EqualTo()(object_0_0, object_0_1)); const auto object_1 = factory.get_or_create("object_1", TypeList()); EXPECT_EQ(factory.size(), 2); EXPECT_NE(object_0_0, object_1); EXPECT_EQ(object_1->get_index(), 1); EXPECT_EQ(object_1->get_name(), "object_1"); - EXPECT_NE(ShallowHash()(object_0_0), ShallowHash()(object_1)); - EXPECT_FALSE(ShallowEqualTo()(object_0_0, object_1)); + EXPECT_NE(Hasher()(object_0_0), Hasher()(object_1)); + EXPECT_FALSE(EqualTo()(object_0_0, object_1)); } }