ALib C++ Library
by
Library Version:
2402 R1
Documentation generated by
Loading...
Searching...
No Matches
home
dev
A-Worx
ALib
src
alib
monomem
hashset.hpp
Go to the documentation of this file.
1
/** ************************************************************************************************
2
* \file
3
* This header file is part of module \alib_monomem of the \aliblong.
4
*
5
* \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6
* Published under \ref mainpage_license "Boost Software License".
7
**************************************************************************************************/
8
#ifndef HPP_ALIB_MONOMEM_HASHSET
9
#define HPP_ALIB_MONOMEM_HASHSET 1
10
11
#if !defined(HPP_ALIB_MONOMEM_HASHTABLE)
12
# include "
alib/monomem/hashtable.hpp
"
13
#endif
14
15
16
namespace
alib
{
namespace
monomem {
namespace
detail {
17
18
/**
19
* Helper struct used for implementing \alib{monomem;HashSet}.
20
* This type is used as template parameter \p{TAccess} of \alib{monomem;HashTable}.
21
*
22
* @tparam TStored The object type stored in the set, which is the same as the key type.
23
*/
24
template
<
typename
TStored>
25
struct
HashSetAccess
26
{
27
/** Returns the given \p{src} as is.
28
* @param src The value of the element to hash.
29
* @return The key-portion of the stored value. */
30
TStored&
Key
(TStored& src)
const
31
{
32
return
src;
33
}
34
35
/** This will never be called. */
36
void
Mapped
(TStored&)
const
37
{}
38
};
39
40
}
// namespace alib::monomem[::detail]
41
42
/** ************************************************************************************************
43
* This type definition is a shortcut to \alib{monomem;HashTable}, usable if the full portion of
44
* the data stored in the container is used for the comparison of values.
45
*
46
* \note
47
* As with this definition template type \p{TKey} equals inserted type \p{T}, methods of
48
* target type \alib{monomem;HashTable} that accept an object of template type \b TKey
49
* expect an object of \p{T} when this type is used.
50
*
51
* \see
52
* For a detailed description of this type, see original type \alib{monomem;HashTable}.<br>
53
* Another type definition based on \b %HashTable is provided with \alib{monomem;HashMap}.
54
*
55
* @tparam T The element type stored with this container.
56
* This type is published as \alib{monomem;HashTable::ValueType} and type
57
* definition \alib{monomem;HashTable::KeyType} becomes a synonym.
58
* @tparam THash The hash functor applicable to \p{TKey}.<br>
59
* Defaults to <c>std::hash<TKey></c> and is published as
60
* \alib{monomem;HashTable::HashType}.
61
* @tparam TEqual The comparison functor on \p{TKey}.<br>
62
* Defaults to <c>std::equal_to<TKey></c> and is published as
63
* \alib{monomem;HashTable::EqualType}.
64
* @tparam THashCaching Determines if hash codes are cached when elements are inserted.<br>
65
* Defaults to <b>Caching::Auto</b>, which enables caching if
66
* <c>std::is_arithmetic<T>::value</c> evaluates to \c false.
67
* @tparam TRecycling Denotes the type of recycling that is to be performed. Possible values are
68
* \alib{monomem;Recycling::Private} (the default),
69
* \alib{monomem;Recycling::Shared} or \alib{monomem;Recycling::None}.
70
**************************************************************************************************/
71
template
<
typename
T,
72
typename
THash = std::hash <T>,
73
typename
TEqual = std::equal_to<T>,
74
lang::Caching
THashCaching =
lang::Caching::Auto
,
75
typename
TRecycling =
Recycling::Private
>
76
using
HashSet
=
monomem::HashTable
< T, T,
77
T, void,
78
THash,
79
TEqual,
80
monomem::detail::HashSetAccess<T>
,
81
THashCaching,
82
TRecycling >;
83
84
85
86
}
// namespace alib[::monomem]
87
88
/// Type alias in namespace \b alib. See type definition \ref alib::monomem::HashSet.
89
template
<
typename
T,
90
typename
THash = std::hash <T>,
91
typename
TEqual = std::equal_to<T>,
92
lang::Caching
THashCaching =
lang::Caching::Auto
,
93
typename
TRecycling =
monomem::Recycling::Private
>
94
using
HashSet
=
monomem::HashSet<T, THash, TEqual, THashCaching, TRecycling >
;
95
96
97
}
// namespace [alib]
98
99
#endif
// HPP_ALIB_MONOMEM_HASHSET
alib::monomem::HashTable
Definition
hashtable.hpp:454
hashtable.hpp
alib::lang::Caching
Caching
Definition
commonenumdefs.hpp:56
alib::lang::Caching::Auto
@ Auto
Auto/default mode.
alib
Definition
alib.cpp:57
alib::monomem::Recycling::Private
Definition
monomem/fwds.hpp:36
alib::monomem::detail::HashSetAccess
Definition
hashset.hpp:26
alib::monomem::detail::HashSetAccess::Key
TStored & Key(TStored &src) const
Definition
hashset.hpp:30
alib::monomem::detail::HashSetAccess::Mapped
void Mapped(TStored &) const
Definition
hashset.hpp:36