I have a lobby server and I'm adding data about online users in a vector. So far, when it comes to activities in which I must set a state for only one particular user I've been iterating through my vector to find the specific user by the nick. I'm doing so everytime and I'm wondering if there's any better solution? I don't want to iterate through all my users each time I have to set something to only one of them. If a client could send his genuine index of his place in my server's vector that would be cool but once client sent a message with his index, other users could disconnect - server's vector would be shortened and therefore the index wouldn't be correct anymore. I can't think on how to implement such mechanism. It needs a lot of synchronisation but maybe there are better means?
I will be grateful for any suggestions!