Click here to Skip to main content
16,006,817 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to load map of maps Pin
b-rad31126-May-10 11:52
b-rad31126-May-10 11:52 
GeneralRe: how to load map of maps Pin
David Crow26-May-10 17:21
David Crow26-May-10 17:21 
QuestionRe: how to load map of maps Pin
David Crow26-May-10 3:41
David Crow26-May-10 3:41 
AnswerRe: how to load map of maps Pin
b-rad31126-May-10 3:48
b-rad31126-May-10 3:48 
GeneralRe: how to load map of maps Pin
Aescleal26-May-10 4:02
Aescleal26-May-10 4:02 
GeneralRe: how to load map of maps Pin
El Corazon26-May-10 15:39
El Corazon26-May-10 15:39 
GeneralRe: how to load map of maps [modified] Pin
b-rad31127-May-10 3:39
b-rad31127-May-10 3:39 
GeneralRe: how to load map of maps Pin
El Corazon27-May-10 5:17
El Corazon27-May-10 5:17 
b-rad311 wrote:
Thanks for replying. I am storing forces and moments (so double or long doubles) for an engineering application.


You definitely don't want a map of maps because it doesn't sound like you have two indexes. You could use a map of a structure, or pair, and use the one index of time. However... at one million entries you are going to start noticing the significant hit of the search through the map.

start with a quick review of performance considerations on STL:
GDC 2001 Round Table Report[^]
Custom STL Allocators (Power Point Presentation)[^]
Common Performance Mistakes in Games (Power Point Presentation)[^] (this is my favorite)

Ignore that the latter is for the Xbox, the issues are the same. Games require performance, performance on STL containers are a common problem, but usually because of a misunderstanding of how they work. When do you make your own? why? how? do you leverage the existing STL work when you do? (yes!!)

If your time is sampled at a constant rate you directly turn time into an index, so I would use a vector, but I would pre-allocate memory with reserve such that the allocation occurs only once at the beginning and there after, random access direct memory speed will beat anything hands down.

If you sample rate is not constant, and you need random access over linear reading, you can consider an STL form of a Hash when you get into a large data sets. There are still two possibilities: one-time hash, or bucket hash. One-time hashes are hard to set up, usually meaning you allocate more memory than you need by 50% in a vector, then generate an index from your time using a mathematical hash function which converts your key directly to an index value. If you choose your hash function well for your key-type, this works well, but requires more memory. If you choose your hash function poorly, your tend to reallocate when you hit duplicate keys to the a given index and there goes your performance down the tubes again.... A bucket hash is kind of compromise. You use a smaller vector as the hash, but duplicates are stored in individual lists or maps (the buckets).

The bad news is that hashes do not have a really good way of accessing the values in order, it is strictly a random access method. If you need linear reads, I would go with a reserve value on a vector to improve vector performance. You can also do the same with a map, but maps allocate blocks as you go, without recycling old allocations, so it usually isn't necessary.

I used to have a table of STL performance values for each key function (push back, push front, insert, find, iterators, etc), but I can't seem to find it with google at the moment and I have to jump back to my work for a while. Think over what you have, how you intend to read it, how you can read it too.

Good luck!
_________________________
John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."

Shhhhh.... I am not really here. I am a figment of your imagination.... I am still in my cave so this must be an illusion....

GeneralRe: how to load map of maps Pin
b-rad31127-May-10 5:42
b-rad31127-May-10 5:42 
GeneralRe: how to load map of maps Pin
El Corazon27-May-10 6:33
El Corazon27-May-10 6:33 
GeneralRe: how to load map of maps Pin
El Corazon27-May-10 6:56
El Corazon27-May-10 6:56 
AnswerRe: how to load map of maps Pin
Aescleal26-May-10 3:49
Aescleal26-May-10 3:49 
GeneralRe: how to load map of maps Pin
b-rad31126-May-10 4:23
b-rad31126-May-10 4:23 
QuestionSDK Pin
john563226-May-10 3:08
john563226-May-10 3:08 
AnswerRe: SDK Pin
Richard MacCutchan26-May-10 4:28
mveRichard MacCutchan26-May-10 4:28 
Questionhow to show dynamic values in the clistctrl Pin
manoharbalu26-May-10 1:21
manoharbalu26-May-10 1:21 
AnswerRe: how to show dynamic values in the clistctrl Pin
Code-o-mat26-May-10 1:47
Code-o-mat26-May-10 1:47 
GeneralRe: how to show dynamic values in the clistctrl Pin
manoharbalu26-May-10 2:05
manoharbalu26-May-10 2:05 
GeneralRe: how to show dynamic values in the clistctrl Pin
Code-o-mat26-May-10 2:27
Code-o-mat26-May-10 2:27 
GeneralRe: how to show dynamic values in the clistctrl Pin
manoharbalu26-May-10 3:00
manoharbalu26-May-10 3:00 
GeneralRe: how to show dynamic values in the clistctrl Pin
Code-o-mat26-May-10 3:07
Code-o-mat26-May-10 3:07 
QuestionRe: how to show dynamic values in the clistctrl Pin
David Crow26-May-10 3:08
David Crow26-May-10 3:08 
QuestionCStatic as Text and Float Pin
Anu_Bala26-May-10 0:16
Anu_Bala26-May-10 0:16 
AnswerRe: CStatic as Text and Float Pin
Maximilien26-May-10 0:44
Maximilien26-May-10 0:44 
AnswerRe: CStatic as Text and Float Pin
Aescleal26-May-10 1:14
Aescleal26-May-10 1:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.