SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
hash.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
15 #include <seqan3/alphabet/hash.hpp>
17 #include <seqan3/range/concept.hpp>
18 #include <seqan3/std/ranges>
19 
20 namespace std
21 {
27 template <ranges::input_range urng_t>
31 struct hash<urng_t>
32 {
39  template <ranges::input_range urng2_t>
43  size_t operator()(urng2_t && range) const noexcept
44  {
45  using alphabet_t = std::ranges::range_reference_t<urng_t>;
46  size_t result{0};
47  hash<alphabet_t> h{};
48  for (alphabet_t character : range)
49  {
50  result *= seqan3::alphabet_size<alphabet_t>;
51  result += h(character);
52  }
53  return result;
54  }
55 };
56 
57 } // namespace std
concept.hpp
Additional non-standard concepts for ranges.
std::hash< urng_t >::operator()
size_t operator()(urng2_t &&range) const noexcept
Compute the hash for a range of characters.
Definition: hash.hpp:43
range.hpp
Provides various transformation traits used by the range module.
ranges
Adaptations of concepts from the Ranges TS.
std::hash< alphabet_t >
Struct for hashing a character.
Definition: hash.hpp:27
std
SeqAn specific customisations in the standard namespace.
semialphabet
The basis for seqan3::alphabet, but requires only rank interface (not char).
hash.hpp
Provides overloads for std::hash.
std::hash