NameSuggester
Suggests unique names with a "name (N)" disambiguation scheme.
| Declared in | src/libs/libutil/utility/string/NameSuggester.hpp |
| Group | util |
Detailed description
Replaces ad-hoc "name copy", "name copy copy" patterns with a consistent, idempotent scheme:
- "foo" -> "foo (2)"
- "foo (2)" -> "foo (3)"
- "foo (3)" with {"foo","foo (3)"} present -> "foo (4)"
- "foo" with {"foo","foo (2)","foo (3)"} present -> "foo (4)"
The base name is extracted by stripping a trailing " (N)" suffix when present, so duplicating an already-disambiguated item produces the next free index in the same family rather than appending another suffix.
Conflicts are resolved by walking the counter forward until a free slot is found, so duplicating any member of a sparse family yields a name that is guaranteed not to collide with existing items.