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());
70 }
while (result == keyValMap.end() and curKey.has_value());
92 template <
typename KeyT,
typename ValueT>
93 typename std::map<KeyT, ValueT>::const_iterator
95 const std::map<KeyT, ValueT>& keyValMap,
96 const std::function<std::optional<KeyT>(KeyT&)>& prefixFunc,
98 const std::function<
bool(
const KeyT&,
const ValueT&)>& predicate)
100 std::optional<KeyT> curKey = key;
102 typename std::map<KeyT, ValueT>::const_iterator result = keyValMap.end();
105 auto iterator = keyValMap.find(curKey.value());
106 if (iterator != keyValMap.end() and predicate(iterator->first, iterator->second))
112 curKey = prefixFunc(curKey.value());
114 }
while (result == keyValMap.end() and curKey.has_value());
134 template <
typename KeyT,
typename ValueT,
typename AccumulateT>
137 const std::map<KeyT, ValueT>& keyValMap,
138 const std::function<std::optional<KeyT>(
const KeyT&)>& prefixFunc,
139 const std::function<
void(AccumulateT&,
const ValueT&)> accumulateFunc,
142 std::optional<KeyT> curKey = key;
146 const auto nextEntry =
148 if (nextEntry != keyValMap.end())
150 curKey = prefixFunc(nextEntry->first);
151 accumulateFunc(values, nextEntry->second);
157 }
while (curKey.has_value());
173 template <
typename KeyT,
typename ValueT>
176 const std::function<std::optional<KeyT>(
const KeyT&)>& prefixFunc,
182 [](std::vector<ValueT>& values,
const ValueT& val) { values.push_back(val); },
197 template <
typename KeyT,
typename ValueT>
200 const std::function<std::optional<KeyT>(
const KeyT&)>& prefixFunc,
206 [](std::vector<ValueT>& values,
const std::vector<ValueT>& val)
207 { values.insert(values.end(), val.begin(), val.end()); },
229 template <
typename ValueT>
230 typename std::map<MemoryID, ValueT>::const_iterator
243 template <
typename ValueT>
244 typename std::map<MemoryID, ValueT>::const_iterator
246 const std::map<MemoryID, ValueT>& idMap,
248 const std::function<
bool(
const MemoryID&,
const ValueT&)>& predicate)
259 template <
typename ValueT>
271 template <
typename ValueT>
bool hasMemoryName() const
MemoryID removeLeafItem() const
AccumulateT accumulateFromPrefixes(const std::map< KeyT, ValueT > &keyValMap, const std::function< std::optional< KeyT >(const KeyT &)> &prefixFunc, const std::function< void(AccumulateT &, const ValueT &)> accumulateFunc, const KeyT &key)
Accumulate all the values in a map for which the keys are prefixes of the given key.
std::map< KeyT, ValueT >::const_iterator findEntryWithLongestPrefix(const std::map< KeyT, ValueT > &keyValMap, const std::function< std::optional< KeyT >(KeyT &)> &prefixFunc, const KeyT &key)
Get the entry in the map for which the returned key is the longest prefix of the given key among the ...
std::map< KeyT, ValueT >::const_iterator findEntryWithLongestPrefixAnd(const std::map< KeyT, ValueT > &keyValMap, const std::function< std::optional< KeyT >(KeyT &)> &prefixFunc, const KeyT &key, const std::function< bool(const KeyT &, const ValueT &)> &predicate)
Get the entry in the map for which the returned key is the longest prefix of the given key among the ...
std::vector< ValueT > accumulateEntriesContainingID(const std::map< MemoryID, ValueT > &idMap, const MemoryID &id)
Return all values of keys containing the given ID.
std::optional< MemoryID > getMemoryIDParent(const MemoryID &memID)
std::map< MemoryID, ValueT >::const_iterator findMostSpecificEntryContainingID(const std::map< MemoryID, ValueT > &idMap, const MemoryID &id)
Find the entry with the most specific key that contains the given ID, or idMap.end() if no key contai...
std::map< MemoryID, ValueT >::const_iterator findMostSpecificEntryContainingIDAnd(const std::map< MemoryID, ValueT > &idMap, const MemoryID &id, const std::function< bool(const MemoryID &, const ValueT &)> &predicate)
Find the entry with the most specific key that contains the given ID and satisfies the predicate,...