D
deancoo
Being fairly new to STL, I'm looking for a little advice on which container
to use. Let me set up the scenario for you to consider. Suppose you're
trying to model a hotel. The hotel has a fixed number of hotel rooms (10
say), each of which may or may not contain a guest. Guests come and go.
You would at some point need to visit each guest in sequence (to clean
rooms), and you will need to visit them independently (for say a package
delivery).
Because of the fixed number of rooms in this example, I was originally
thinking about using an associative container like map, where you could
associate an int (room number) with an object (guest). As guests come or
go, you assign or delete objects from the map as needed. However, I'm not
so sure how well a map iterates through each of its elements compared to a
sequence container. Anyway, any advice offered would be appreciated.
d
to use. Let me set up the scenario for you to consider. Suppose you're
trying to model a hotel. The hotel has a fixed number of hotel rooms (10
say), each of which may or may not contain a guest. Guests come and go.
You would at some point need to visit each guest in sequence (to clean
rooms), and you will need to visit them independently (for say a package
delivery).
Because of the fixed number of rooms in this example, I was originally
thinking about using an associative container like map, where you could
associate an int (room number) with an object (guest). As guests come or
go, you assign or delete objects from the map as needed. However, I'm not
so sure how well a map iterates through each of its elements compared to a
sequence container. Anyway, any advice offered would be appreciated.
d