472,801 Members | 1,155 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,801 software developers and data experts.

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 1538
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):...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.