I have the following scenario. Implementation is required for a real-time application.
1) I need to store a maximum of 20 entries in a container (STL Map, STL List, etc.). 2) If there is a new record, and already 20 records, I have to overwrite the old record with a new record.
Given point 2, I feel that the container is full (maximum 20 entries) "list" is the best bet since I can always delete the first entry in the list and add a new one finally (push_back). However, the search will not be so effective.
For only 20 entries, is this really significant in terms of search efficiency if I use a list instead of a map?
Also, given the cost of inserting on the map, do I feel I have to go after the list?
Could you tell me which is better for me?
source
share