You associate the names with the objects, it is entirely up to you what you want to do with the names. The name does not have to be a list index, it could be cast from a pointer for example.
I’m going to answer, but I also want a moderator to move the answer to the “for beginners” section.
Anyway:
For each object, allocate a struct, which allows you to keep track of the object, which group it is in, etc.
The pointer to this struct can be cast to an int, on all 32-bit platforms, and on 64-bit platforms with 64-bit ints. Cast the pointer-to-struct to int for each object.
This casted pointer is your name. Now, when you get a specific name back, you just cast back to pointer, and dereference – voila, there is a struct telling you what the object is!
If you need to do this on a platform where names are 32 bit, but pointers are 64 bit, you can also just put all the different struct pointers into a vector, and make the index into the vector be the name.