SeqAn3  3.2.0
The Modern C++ library for sequence analysis.
range/hash.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2022, 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 <ranges>
16 
17 #include <seqan3/alphabet/hash.hpp>
19 
20 namespace std
21 {
29 template <std::ranges::input_range urng_t>
31 struct hash<urng_t>
32 {
41  template <std::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
Provides various transformation traits used by the range module.
Provides overloads for std::hash.
The basis for seqan3::alphabet, but requires only rank interface (not char).
SeqAn specific customisations in the standard namespace.
The <ranges> header from C++20's standard library.
Struct for hashing a character.
Definition: hash.hpp:28
requires seqan3::semialphabet< std::ranges::range_reference_t< urng2_t > > size_t operator()(urng2_t &&range) const noexcept
Compute the hash for a range of characters.
Definition: range/hash.hpp:43