MCPcopy Create free account
hub / github.com/comaps/comaps / GetTopmostNodesFor

Method GetTopmostNodesFor

libs/storage/storage.cpp:2234–2256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2232}
2233
2234void Storage::GetTopmostNodesFor(CountryId const & countryId, CountriesVec & nodes, size_t level) const
2235{
2236 nodes.clear();
2237
2238 CountryTree::NodesBufferT treeNodes;
2239 m_countries.Find(countryId, treeNodes);
2240 if (treeNodes.empty())
2241 {
2242 LOG(LWARNING, ("CountryId =", countryId, "not found in m_countries."));
2243 return;
2244 }
2245
2246 nodes.resize(treeNodes.size());
2247 for (size_t i = 0; i < treeNodes.size(); ++i)
2248 {
2249 nodes[i] = countryId;
2250 CountriesVec path;
2251 ForEachAncestorExceptForTheRoot(
2252 {treeNodes[i]}, [&path](CountryId const & id, CountryTree::Node const &) { path.emplace_back(id); });
2253 if (!path.empty() && level < path.size())
2254 nodes[i] = path[path.size() - 1 - level];
2255 }
2256}
2257
2258CountryId const Storage::GetParentIdFor(CountryId const & countryId) const
2259{

Callers 3

UNIT_TESTFunction · 0.80
SetPlacePageLocationMethod · 0.80

Calls 6

clearMethod · 0.45
FindMethod · 0.45
emptyMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.64