MCPcopy Create free account
hub / github.com/DFHack/dfhack / findPrefixInMap

Function findPrefixInMap

library/include/MiscUtils.h:380–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378
379template<typename T>
380typename T::mapped_type findPrefixInMap(
381 const T &table, const std::string &key,
382 const typename T::mapped_type& defval = typename T::mapped_type()
383) {
384 auto it = table.lower_bound(key);
385 if (it != table.end() && it->first == key)
386 return it->second;
387 if (it != table.begin()) {
388 --it;
389 if (prefix_matches(it->first, key))
390 return it->second;
391 }
392 return defval;
393}
394
395#ifdef __GNUC__
396#define VARIABLE_IS_NOT_USED __attribute__ ((unused))

Callers

nothing calls this directly

Calls 3

prefix_matchesFunction · 0.85
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected