468,765 Members | 1,066 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

fast insertion and search - STL

Hi,

I would like to know how can I build a structure or an object to quickly
reference the following information :

I need to associate a unique identifier with a list of records
ex :

----------
id: 0x17 |
rec:1,2,3 |
----------

----------
id: 0x18 |
rec:2 |
----------

or maybe it is faster to have a list and to do that

----------
id: 0x17 |
rec:1 |
----------

----------
id: 0x17 |
rec:2 |
----------

----------
id: 0x17 |
rec:3 |
----------

----------
id: 0x18 |
rec:2 |
----------
What kind of container would you use ?
And I would like to be able to write: obj.AddItem(id, rec);//This method
add a new id,rec if it doesn't already exist.

I was thinking of this : map<int, list<int> updateList;
Sorry for this newbie question.

Jul 23 '05 #1
1 1482
Vince wrote:
I would like to know how can I build a structure or an object to quickly
reference the following information :

I need to associate a unique identifier with a list of records
ex :

----------
id: 0x17 |
rec:1,2,3 |
----------

----------
id: 0x18 |
rec:2 |
----------

or maybe it is faster to have a list and to do that

----------
id: 0x17 |
rec:1 |
----------

----------
id: 0x17 |
rec:2 |
----------

----------
id: 0x17 |
rec:3 |
----------

----------
id: 0x18 |
rec:2 |
----------
What kind of container would you use ?
And I would like to be able to write: obj.AddItem(id, rec);//This method
add a new id,rec if it doesn't already exist.

I was thinking of this : map<int, list<int> updateList;


map<int, set<int> > might be a bit more robust if the record numbers
have to be unique, but the list should work well too. If you want to
keep pairs, you should look at multimap<int,int>.

V
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by N. | last post: by
2 posts views Thread by Kushal | last post: by
20 posts views Thread by Patrick Guio | last post: by
18 posts views Thread by David Frank | last post: by
6 posts views Thread by G.Esmeijer | last post: by
4 posts views Thread by Raider | last post: by
2 posts views Thread by ndbecker2 | last post: by
5 posts views Thread by Naveen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.