| 62 | } |
| 63 | |
| 64 | void Base::UniqueNameManager::addExactName(std::string_view name) |
| 65 | { |
| 66 | const auto [namePrefix, nameSuffix, digitCount, digitsValue] = decomposeName(name); |
| 67 | std::string baseName {namePrefix}; |
| 68 | baseName += nameSuffix; |
| 69 | auto baseNameEntry = uniqueSeeds.find(baseName); |
| 70 | if (baseNameEntry == uniqueSeeds.end()) { |
| 71 | // First use of baseName |
| 72 | baseNameEntry |
| 73 | = uniqueSeeds |
| 74 | .emplace(baseName, std::vector<PiecewiseSparseIntegerSet<UnlimitedUnsigned>>()) |
| 75 | .first; |
| 76 | } |
| 77 | if (digitCount >= baseNameEntry->second.size()) { |
| 78 | // First use of this digitCount |
| 79 | baseNameEntry->second.resize(digitCount + 1); |
| 80 | } |
| 81 | PiecewiseSparseIntegerSet<UnlimitedUnsigned>& baseNameAndDigitCountEntry |
| 82 | = baseNameEntry->second[digitCount]; |
| 83 | |
| 84 | if (baseNameAndDigitCountEntry.contains(digitsValue)) { |
| 85 | // We already have at least one instance of the name. |
| 86 | // Increment the duplicateCounts entry for that name, |
| 87 | // making one if none is present with an initial count of 1 |
| 88 | // representing the singleton element we already have. |
| 89 | duplicateCounts.try_emplace(std::string {name}, 1U).first->second++; |
| 90 | return; |
| 91 | } |
| 92 | baseNameAndDigitCountEntry.add(digitsValue); |
| 93 | } |
| 94 | std::string Base::UniqueNameManager::makeUniqueName(std::string_view modelName, std::size_t minDigits) const |
| 95 | { |
| 96 | auto [namePrefix, nameSuffix, digitCount, digitsValue] = decomposeName(modelName); |
no test coverage detected