SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
hash.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, 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/std/ranges>
16 
17 #include <seqan3/alphabet/hash.hpp>
19 
20 namespace std
21 {
29 template <ranges::input_range urng_t>
33 struct hash<urng_t>
34 {
43  template <ranges::input_range urng2_t>
47  size_t operator()(urng2_t && range) const noexcept
48  {
49  using alphabet_t = std::ranges::range_reference_t<urng_t>;
50  size_t result{0};
51  hash<alphabet_t> h{};
52  for (alphabet_t character : range)
53  {
54  result *= seqan3::alphabet_size<alphabet_t>;
55  result += h(character);
56  }
57  return result;
58  }
59 };
60 
61 } // namespace std
Provides overloads for std::hash.
Provides various transformation traits used by the range module.
The basis for seqan3::alphabet, but requires only rank interface (not char).
SeqAn specific customisations in the standard namespace.
Adaptations of concepts from the Ranges TS.
Struct for hashing a character.
Definition: hash.hpp:30
size_t operator()(urng2_t &&range) const noexcept
Compute the hash for a range of characters.
Definition: hash.hpp:47