1//
2// HashFunction.h
3//
4// Library: Foundation
5// Package: Hashing
6// Module: HashFunction
7//
8// Definition of the HashFunction class.
9//
10// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef Foundation_HashFunction_INCLUDED
18#define Foundation_HashFunction_INCLUDED
19
20
21#include "Poco/Foundation.h"
22#include "Poco/Hash.h"
23
24
25namespace Poco {
26
27
28//@ deprecated
29template <class T>
30struct HashFunction
31 /// A generic hash function.
32{
33 UInt32 operator () (T key, UInt32 maxValue) const
34 /// Returns the hash value for the given key.
35 {
36 return static_cast<UInt32>(Poco::hash(key)) % maxValue;
37 }
38};
39
40
41//@ deprecated
42template <>
43struct HashFunction<std::string>
44 /// A generic hash function.
45{
46 UInt32 operator () (const std::string& key, UInt32 maxValue) const
47 /// Returns the hash value for the given key.
48 {
49 return static_cast<UInt32>(Poco::hash(key)) % maxValue;
50 }
51};
52
53
54} // namespace Poco
55
56
57#endif // Foundation_HashFunctions_INCLUDED
58