50 template <
typename KeyT,
typename ValueT>
51 typename std::map<KeyT, ValueT>::const_iterator
53 const std::function<std::optional<KeyT>(KeyT&)>& prefixFunc,
56 std::optional<KeyT> curKey = key;
58 typename std::map<KeyT, ValueT>::const_iterator result = keyValMap.end();
61 auto iterator = keyValMap.find(curKey.value());
62 if (iterator != keyValMap.end())
68 curKey = prefixFunc(curKey.value());
71 while (result == keyValMap.end() and curKey.has_value());
93 template <
typename KeyT,
typename ValueT>
94 typename std::map<KeyT, ValueT>::const_iterator
96 const std::map<KeyT, ValueT>& keyValMap,
97 const std::function<std::optional<KeyT>(KeyT&)>& prefixFunc,
99 const std::function<
bool(
const KeyT&,
const ValueT&)>& predicate)
101 std::optional<KeyT> curKey = key;
103 typename std::map<KeyT, ValueT>::const_iterator result = keyValMap.end();
106 auto iterator = keyValMap.find(curKey.value());
107 if (iterator != keyValMap.end() and predicate(iterator->first, iterator->second))
113 curKey = prefixFunc(curKey.value());
116 while (result == keyValMap.end() and curKey.has_value());
136 template <
typename KeyT,
typename ValueT,
typename AccumulateT>
139 const std::function<std::optional<KeyT>(
const KeyT&)>& prefixFunc,
140 const std::function<
void(AccumulateT&,
const ValueT&)> accumulateFunc,
143 std::optional<KeyT> curKey = key;
147 const auto nextEntry =
148 findEntryWithLongestPrefix<KeyT, ValueT>(keyValMap, prefixFunc, curKey.value());
149 if (nextEntry != keyValMap.end())
151 curKey = prefixFunc(nextEntry->first);
152 accumulateFunc(
values, nextEntry->second);
159 while (curKey.has_value());
175 template <
typename KeyT,
typename ValueT>
178 const std::function<std::optional<KeyT>(
const KeyT&)>& prefixFunc,
181 return accumulateFromPrefixes<KeyT, ValueT, std::vector<ValueT>>(
184 [](std::vector<ValueT>&
values,
const ValueT& val) {
values.push_back(val); },
199 template <
typename KeyT,
typename ValueT>
202 const std::function<std::optional<KeyT>(
const KeyT&)>& prefixFunc,
205 return accumulateFromPrefixes<KeyT, std::vector<ValueT>, std::vector<ValueT>>(
208 [](std::vector<ValueT>&
values,
const std::vector<ValueT>& val)
209 {
values.insert(
values.end(), val.begin(), val.end()); },
233 template <
typename ValueT>
234 typename std::map<MemoryID, ValueT>::const_iterator
237 return detail::findEntryWithLongestPrefix<MemoryID, ValueT>(idMap, &
getMemoryIDParent,
id);
248 template <
typename ValueT>
249 typename std::map<MemoryID, ValueT>::const_iterator
251 const std::function<
bool(
const MemoryID&,
const ValueT&)>& predicate)
253 return detail::findEntryWithLongestPrefixAnd<MemoryID, ValueT>(
263 template <
typename ValueT>
267 return detail::accumulateFromPrefixes<MemoryID, ValueT>(idMap, &
getMemoryIDParent,
id);
276 template <
typename ValueT>
281 return detail::accumulateFromPrefixes<MemoryID, ValueT>(idMap, &
getMemoryIDParent, key);