SeqAn3 3.2.0
The Modern C++ library for sequence analysis.
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
19
20namespace std
21{
29template <std::ranges::input_range urng_t>
31struct 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};
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.
Struct for hashing a character.
Definition: hash.hpp:28
size_t operator()(urng2_t &&range) const noexcept
Compute the hash for a range of characters.
Definition: hash.hpp:43