0

I am writing a small software which deals with inter-process multicast. For each message, on each process, I have a couple of variables assigned to the message itself:

messageID
senderID
ack1
ack2
ack3
...

I would like to put these elements (which are many) in a container, so that it is later easy to perform operations such as changing the value of ack1 for a given messageID (I should keep trace of which processes in my group notified me that they got the message).

Which is the best container to use in this case?

Thanks

1
  • 1
    Are your MessageIDs unique identifiers for each message? Commented Mar 8, 2011 at 14:56

3 Answers 3

1

You might want to use std::map or boost::unordered_map (soon to be standard) as you can access it by message id.
Next time you'd want to answer such a question alone, take a look at this diagram.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the diagram, too! :)
@Danilo The appropriate way to acknowledge a good answer is an upvote in stackoverflow. You are more than welcome to do so :)
1

You can use a map to easily fetch a structure by messageID: http://www.cplusplus.com/reference/stl/map/

1 Comment

boost::multi_map or c++0x multimap.
1

In addition to std::map and boost::unordered_map, if you plan to iterate over the messages from a given senderID you can use boost::multi_index_container.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.