10#ifndef MCRL2_ATERMPP_DETAIL_ATERM_HASH_H_
11#define MCRL2_ATERMPP_DETAIL_ATERM_HASH_H_
34 return reinterpret_cast<std::uintptr_t
>(term) >> 4;
44 const std::hash<atermpp::detail::_aterm*> hasher;
55 const std::hash<atermpp::detail::_aterm*> aterm_hasher;
73template<std::
size_t N = DynamicNumberOfArguments>
82 template<
typename ForwardIterator,
83 typename std::enable_if<mcrl2::utilities::is_iterator<ForwardIterator>::value,
void>::type* =
nullptr>
89template<std::
size_t N = 0>
97 template<
typename ...Args>
107 inline std::size_t
operator()(std::size_t value)
const noexcept;
113template<std::
size_t N = DynamicNumberOfArguments>
122 template<
typename ForwardIterator,
123 typename std::enable_if<mcrl2::utilities::is_iterator<ForwardIterator>::value>::type* =
nullptr>
127template<std::
size_t N>
133 template<
typename ...Args>
150 const std::hash<unprotected_aterm_core> hasher;
156template<std::
size_t N>
160 std::size_t hnr = operator()(f);
167 for (std::size_t i = 0; i < arity; ++i)
174template<std::
size_t N>
177 const std::hash<function_symbol> function_hasher;
178 return function_hasher(symbol);
181template<std::
size_t N>
188 std::size_t hnr = operator()(symbol);
189 for (std::size_t i = 0; i < arity; ++i)
191 hnr =
combine(hnr, arguments[i]);
197template<std::
size_t N>
198template<
typename ForwardIterator,
199 typename std::enable_if<mcrl2::utilities::is_iterator<ForwardIterator>::value,
void>::type*>
209 std::size_t hnr = operator()(symbol);
210 for (std::size_t i = 0; i < arity; ++i)
221template<std::
size_t N>
224 std::size_t hnr = operator()(symbol);
227 for (std::size_t i = 0; i < N; ++i)
229 hnr =
combine(hnr, arguments[i]);
235template<std::size_t I = 0,
typename... Tp,
236 typename std::enable_if<I ==
sizeof...(Tp),
void>::type* =
nullptr>
242template<std::size_t I = 0,
typename... Tp,
243 typename std::enable_if<I <
sizeof...(Tp),
void>::type* =
nullptr>
244std::size_t
combine_args(std::size_t seed,
const Tp&... t)
246 return combine_args<I+1>(
combine(seed, std::get<I>(std::forward_as_tuple(t...))), t...);
249template<std::
size_t N>
250template<
typename ...Args>
253 std::size_t hnr = operator()(symbol);
261 return aterm_int_hasher()(term.value());
266static inline std::size_t xorshift(
const std::size_t n,
const std::size_t i)
273 const std::size_t p = 0x5555555555555555ull;
274 const std::size_t c = 17316035218449499591ull;
275 return c*xorshift(p*xorshift(value,32),32);
278template<std::
size_t N>
281 if (&first == &second)
291 for (std::size_t i = 0; i < arity; ++i)
293 if (
static_cast<const _term_appl&
>(first).arg(i)
303template<std::
size_t N>
306 return term.function() == symbol;
309template<std::
size_t N>
310bool aterm_equals<N>::operator()(
const _aterm& term,
const function_symbol& symbol, unprotected_aterm_core arguments[])
const noexcept
313 for (std::size_t i = 0; i < symbol.arity(); ++i)
315 if (
static_cast<const _term_appl&
>(term).
arg(i) != arguments[i])
321 return term.function() == symbol;
324template<std::
size_t N>
325template<
typename ForwardIterator,
326 typename std::enable_if<mcrl2::utilities::is_iterator<ForwardIterator>::value>::type*>
327inline bool aterm_equals<N>::operator()(
const _aterm& term,
const function_symbol& symbol, ForwardIterator it, ForwardIterator end)
const noexcept
335 for (std::size_t i = 0; i < arity; ++i)
346 return term.function() == symbol;
349template<std::
size_t N>
353 for (std::size_t i = 0; i <
N; ++i)
355 if (
static_cast<const _aterm_appl<N>&
>(term).
arg(i) != arguments[i])
361 return term.function() == symbol;
364template<std::size_t
I = 0,
366 typename std::enable_if<
I ==
sizeof...(Tp),
void>::type* =
nullptr>
367bool equal_args(
const _aterm_appl<8>&,
const Tp&...)
372template<std::size_t
I = 0,
374 typename std::enable_if<
I <
sizeof...(Tp),
void>::type* =
nullptr>
375bool equal_args(
const _aterm_appl<8>& term,
const Tp&... t)
377 return term.arg(I) == std::get<I>(std::forward_as_tuple(t...)) && equal_args<I+1>(term, t...);
380template<std::
size_t N>
381template<
typename ...Args>
384 return term.function() == symbol && equal_args(
static_cast<const _aterm_appl<8>&
>(term), args...);
389 return (
first.value() == second.value());
394 return (term.value() == value);
The aterm_core base class that provides protection of the underlying shared terms.
const function_symbol & function() const
Returns the function symbol belonging to an aterm.
This class stores a term followed by N arguments. Where N should be equal to the arity of the functio...
const aterm_core & arg(std::size_t index) const
The underlying integer term that actually carries the integer data.
This is the class to which an aterm points.
std::size_t arity() const
Return the arity (number of arguments) of the function symbol (function_symbol).
An unprotected term does not change the reference count of the shared term when it is copied or moved...
This file contains a specialisation for hashes on pairs. This is not a part of the standard,...
This file contains a workaround that allows to assign a small array of elements on the stack....
_aterm * address(const unprotected_aterm_core &t)
std::size_t combine(const std::size_t hnr, const unprotected_aterm_core &term)
Auxiliary function to combine hnr with aterms.
std::size_t combine_args(std::size_t seed, const Tp &...)
_aterm_appl<> _term_appl
A default instantiation for the underlying term application.
constexpr std::size_t DynamicNumberOfArguments
Indicates that the number of arguments is not known at compile time.
The main namespace for the aterm++ library.
data_expression I(const data_expression &x)
normalizer< Function > N(const Function &f)
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
const function_symbol & first()
Constructor for function symbol @first.
std::size_t hash_combine_cheap(const std::size_t seed, const std::size_t hash_number)
Auxiliary function to combine seed with a hash number.
void mcrl2_unused(T &&...)
Function that can be used to silence unused parameter warnings.
bool operator()(const _aterm &term, const function_symbol &symbol, const Args &... args) const noexcept
bool operator()(const _aterm &term, const function_symbol &symbol, std::array< unprotected_aterm_core, N > key) const noexcept
Returns true iff first and second are value-equivalent.
bool operator()(const _aterm &term, const function_symbol &symbol, ForwardIterator begin, ForwardIterator end) const noexcept
bool operator()(const _aterm &first, const _aterm &second) const noexcept
bool operator()(const _aterm &term, const function_symbol &symbol) const noexcept
bool operator()(const _aterm &term, const function_symbol &symbol, unprotected_aterm_core arguments[]) const noexcept
Computes the hash of the given term.
std::size_t operator()(const function_symbol &symbol, const Args &... args) const noexcept
std::size_t operator()(const function_symbol &symbol, std::array< unprotected_aterm_core, N > key) const noexcept
Computes the hash of the given term.
std::size_t operator()(const function_symbol &symbol) const noexcept
std::size_t operator()(const _aterm &term) const noexcept
Implementation.
std::size_t operator()(const function_symbol &symbol, ForwardIterator begin, ForwardIterator end) const noexcept
std::size_t operator()(const function_symbol &symbol, unprotected_aterm_core arguments[]) const noexcept
Returns true iff the given term(s) or value are equivalent.
bool operator()(const _aterm_int &term, std::size_t value) const noexcept
bool operator()(const _aterm_int &first, const _aterm_int &second) const noexcept
Computes the hash of the integral term arguments.
std::size_t operator()(const _aterm_int &term) const noexcept
std::size_t operator()(std::size_t value) const noexcept
std::size_t operator()(const atermpp::aterm_core &t) const
std::size_t operator()(const atermpp::detail::_aterm *term) const
std::size_t operator()(const atermpp::unprotected_aterm_core &term) const