473,473 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1542
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: N. | last post by:
Insertion sort is O(N^2), but I figure I can get it in to O(N log2 N) if the inside loop of the insertion sort is replaced with a binary search. However, I'm having some implimentation problems......
2
by: Kushal | last post by:
Hello, I am trying to build a dynamic set/list of data which should be sorted as each element is inserted. The main criteria in this list is the speed, the time it takes to insert a element,...
20
by: Patrick Guio | last post by:
Dear all, I have some problem with insertion operator together with namespace. I have a header file foo.h containing declaration of classes, typedefs and insertion operators for the typedefs in...
18
by: David Frank | last post by:
Is there a preprocessor (or utility) that has option to insert absent braces to clarify control syntax, ie for/while/if/else/etc ? for(.....) for(....) statement; to
6
by: DC | last post by:
Hi, I am programming a search catalogue with 200000 items (and growing). I am currently using the SQL Server 2000 fulltext engine for this task but it does not fit the requirements anymore. ...
6
by: G.Esmeijer | last post by:
Friends, I would like to read a text file (fixed length formaated) really fast and store the data into an Access database (2003). Using the streamreader and reading line by line, separating the...
4
by: Raider | last post by:
Is there std::map member-function that do as code below? typedef std::map<NameClass, ValueClass> ParameterContainer; .... // this code is equivalent to "_Parameters = Value", // but a bit...
2
by: ndbecker2 | last post by:
I'm looking for an stl-style container that has good performance for insertion and deletion of elements as well as very fast index operation. I'm thinking an stl::list would be good if an...
5
by: Naveen | last post by:
I am trying to write a conatiner which has std::map like methods but preserves the order of insertion. TO achieve this I thought of providing my own function for comparing the keys of the map....
7
by: tatata9999 | last post by:
Hi, SQL env: sql server 2000 Target column of insertion: varchar(15) Case, a var is made up of a character of the following characters (random selection):...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.