TrinityCore
Loading...
Searching...
No Matches
MapUtils.h
Go to the documentation of this file.
1
/*
2
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef TRINITYCORE_MAP_UTILS_H
19
#define TRINITYCORE_MAP_UTILS_H
20
21
#include <type_traits>
22
23
namespace
Trinity::Containers
24
{
28
template
<
class
M>
29
auto
MapGetValuePtr
(M& map,
typename
M::key_type
const
& key)
30
{
31
auto
itr = map.find(key);
32
if
constexpr
(std::is_pointer_v<typename M::mapped_type>)
33
return
itr != map.end() ? itr->second :
nullptr
;
34
else
35
return
itr != map.end() ? &itr->second :
nullptr
;
36
}
37
38
template
<
class
K,
class
V,
template
<
class
,
class
,
class
...>
class
M,
class
... Rest>
39
void
MultimapErasePair
(M<K, V, Rest...>& multimap, K
const
& key, V
const
& value)
40
{
41
auto
range = multimap.equal_range(key);
42
for
(
auto
itr = range.first; itr != range.second;)
43
{
44
if
(itr->second == value)
45
itr = multimap.erase(itr);
46
else
47
++itr;
48
}
49
}
50
}
51
#endif
// TRINITYCORE_MAP_UTILS_H
Trinity::Containers
Definition
FlatSet.h:25
Trinity::Containers::MapGetValuePtr
auto MapGetValuePtr(M &map, typename M::key_type const &key)
Definition
MapUtils.h:29
Trinity::Containers::MultimapErasePair
void MultimapErasePair(M< K, V, Rest... > &multimap, K const &key, V const &value)
Definition
MapUtils.h:39
common
Containers
Utilities
MapUtils.h
Generated on Sun May 10 2026 02:30:12 for TrinityCore by
1.9.8