BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
hash.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2022 deCODE Genetics
3// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
4// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
5// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
6// shipped with this file and also available at: https://github.com/biocpp/biocpp-core/blob/main/LICENSE.md
7// -----------------------------------------------------------------------------------------------------
8
14#pragma once
15
16#include <ranges>
17
18#include <bio/alphabet/hash.hpp>
21
22namespace std
23{
29template <ranges::input_range urng_t>
31struct hash<urng_t>
32{
39 template <ranges::input_range urng2_t>
41 size_t operator()(urng2_t && range) const noexcept
42 {
43 using alphabet_t = std::ranges::range_reference_t<urng_t>;
44 size_t result{0};
46 for (alphabet_t character : range)
47 {
48 result *= bio::alphabet::size<alphabet_t>;
49 result += h(character);
50 }
51 return result;
52 }
53};
54
55} // namespace std
Provides overloads for std::hash.
The basis for bio::alphabet::alphabet, but requires only rank interface (not char).
Definition: concept.hpp:562
Additional non-standard concepts for ranges.
size_t operator()(urng2_t &&range) const noexcept
Compute the hash for a range of characters.
Definition: hash.hpp:41
Provides various transformation traits used by the range module.