I am currently using an std::set<uintptr_t> list
to store unique pointers in it. This list gets bigger with the time and when this list reaches x amount of entries it should delete the first entry, the other entries should move down one and make room for a new entry.
For example:
if (list.count >= 20)
{
list.remove[0]; //remove the first entry from the list?
}
I know this code doesn't work but just for the logic so you know what I mean. Also the first entry would be empty then, would it be possible to move all other entries one down so the [0] entry isn't empty anymore?
CodePudding user response:
You can get the iterator of your first element in your list with list.begin()
if (list.count >= 20)
{
list.erase(list.begin()); //remove the first entry from the list
}