SeqAn3 3.1.0
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
19
20namespace std
21{
29template <ranges::input_range urng_t>
33struct 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};
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 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:30
size_t operator()(urng2_t &&range) const noexcept
Compute the hash for a range of characters.
Definition: hash.hpp:47