MCPcopy Create free account
hub / github.com/davisking/dlib / zero_pad_part_names

Function zero_pad_part_names

dlib/gui_widgets/widgets.cpp:6511–6535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6509 }
6510
6511 void zero_pad_part_names (
6512 std::map<std::string,point>& parts
6513 )
6514 {
6515 if (parts.size() < 5)
6516 return;
6517
6518 const size_t num_digits_required = 1+std::floor(std::log10(parts.size()-1));
6519 // if the first thing in the map has the right number of digits then assume
6520 // everything is fine.
6521 if (parts.begin()->first.size() == num_digits_required)
6522 return;
6523
6524 std::map<std::string,point> new_parts;
6525
6526 for (auto& p : parts)
6527 {
6528 auto key = p.first;
6529 while (key.size() < num_digits_required)
6530 key = '0' + key;
6531 new_parts[key] = p.second;
6532 }
6533
6534 parts.swap(new_parts);
6535 }
6536
6537 }
6538

Callers 1

on_mouse_downMethod · 0.85

Calls 5

log10Function · 0.85
floorFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected