Action Engine
Loading...
Searching...
No Matches
map_util.h
1
// Copyright 2025 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef ACTIONENGINE_UTIL_MAP_UTIL_H_
16
#define ACTIONENGINE_UTIL_MAP_UTIL_H_
17
18
#include <absl/container/flat_hash_map.h>
19
20
namespace
act {
21
template
<
typename
RecordKey,
typename
Value,
typename
QueryKey>
22
Value& FindOrDie(absl::flat_hash_map<RecordKey, Value>& map,
23
const
QueryKey& key) {
24
auto
it = map.find(key);
25
CHECK(it != map.end());
26
return
it->second;
27
}
28
29
template
<
typename
RecordKey,
typename
Value,
typename
QueryKey>
30
const
Value& FindOrDie(
const
absl::flat_hash_map<RecordKey, Value>& map,
31
const
QueryKey& key) {
32
const
auto
it = map.find(key);
33
CHECK(it != map.end());
34
return
it->second;
35
}
36
}
// namespace act
37
38
#endif
// ACTIONENGINE_UTIL_MAP_UTIL_H_
src
actionengine
util
map_util.h
Generated by
1.13.2