If your application should have a naming system in which the application contains 100 actions that create new objects, for example:
Blur
Sharpen
Contrast
Darken
Matte
...
and every time you use one of them, a new instance with a unique editable name, for example Blur01, Blur02, Blur03, Sharpen01, Matte01, etc. How would you generate the next available unique name, so this is an O (1) operation or an almost constant time. Keep in mind that the user can also change the name to user names, for example RemoveFaceDetails, etc.
It is permissible to have some restrictions, for example, limiting the number of characters to 100 using letters, numbers, underscores, etc.
EDIT: You can also offer solutions without "filling in the gaps" that will not reuse already used but deleted names, except for custom ones, of course.
source
share