I wonder is it possible to have a map that would work like boost circular buffer. Meaning it would have limited size and when it would get to its limited size it will start overwriting first inserted elements. Also I want to be capable to search thru such buffer and find or create with [name]. Is It possible to create such thing and how to do it?
I wonder is it possible to have a map that would work like boost
Share
Well, I don’t think that structure is present out of the box in boost (may exist elsewhere, though), so you should create it. I wouldn’t recommend using
operator[](), though, at least as it is implemented instd::map, because this may make difficult to track elements added to the map (for exapmle, usingoperator[]()with a value adds that empty value to the map), and go for a more explicit get and put operations for adding and retrieving elements of the map.As for the easiest implementation, I would go for using an actual
mapas the storage, and adequefor the storage of the elements added (not tested):