Click here to Skip to main content
15,888,802 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Large data sets Pin
ha_ha_ha23-Sep-05 5:06
ha_ha_ha23-Sep-05 5:06 
AnswerRe: Large data sets Pin
Bob Stanneveld19-Sep-05 8:06
Bob Stanneveld19-Sep-05 8:06 
GeneralRe: Large data sets Pin
Obliterator21-Sep-05 4:18
Obliterator21-Sep-05 4:18 
AnswerRe: Large data sets Pin
El Corazon19-Sep-05 8:49
El Corazon19-Sep-05 8:49 
GeneralRe: Large data sets Pin
Obliterator21-Sep-05 4:51
Obliterator21-Sep-05 4:51 
GeneralRe: Large data sets Pin
El Corazon21-Sep-05 6:06
El Corazon21-Sep-05 6:06 
GeneralRe: Large data sets Pin
Obliterator21-Sep-05 6:49
Obliterator21-Sep-05 6:49 
GeneralRe: Large data sets Pin
El Corazon21-Sep-05 15:21
El Corazon21-Sep-05 15:21 
Obliterator wrote:
It looks like std::vector is probably not ideal for my needs.
Maybe I should be looking at std::list?


There are pros and cons on every container, a list offers faster dynamic extention, minimal performance hit moving forwards and backwards through your data, great insertion times, but a larger hit on a search/seek/jump type operation. If your data access is random, you need constant rapid access to your data, a vector is the best container. Because it's memory is uniform and linear in structure, jumping around is VERY fast. If your data access is linear movement, forward or backward, a list makes more sense (not always, but usually). So the question is how often will the user move through the data? if you switch to a list container, you will want to make sure you remove any size() diagnostics, your performance will drop significantly using size() since it basically walks the entire list counting items.


<br />
Summary of Vector Benefits<br />
<br />
Vectors are somewhat easier to use than regular arrays. At the very least, they get around having to be resized constantly using new and delete. Furthermore, their immense flexibility - support for any datatype and support for automatic resizing when adding elements - and the other helpful included functions give them clear advantages to arrays.<br />
<br />
Another argument for using vectors are that they help avoid memory leaks--you don't have to remember to free vectors, or worry about how to handle freeing a vector in the case of an exception. This simplifies program flow and helps you write tighter code. Finally, if you use the at() function to access the vector, you get bounds checking at the cost of a slight performance penalty.<br />
<br />
List Summary<br />
The Good<br />
    * Lists provide fast insertions (in amortized constant time) at the expensive of lookups<br />
    * Lists support bidirectional iterators, but not random access iterators<br />
    * Iterators on lists tend to handle the removal and insertion of surrounding elements well <br />
<br />
The Gotchas<br />
    * Lists are slow to search, and using the size function will take O(n) time<br />
    * Searching for an element in a list will require O(n) time because it lacks support for random access <br />


_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
GeneralRe: Large data sets Pin
Jörgen Sigvardsson19-Sep-05 10:43
Jörgen Sigvardsson19-Sep-05 10:43 
GeneralRe: Large data sets Pin
Obliterator21-Sep-05 4:43
Obliterator21-Sep-05 4:43 
GeneralRe: Large data sets Pin
Jörgen Sigvardsson21-Sep-05 9:25
Jörgen Sigvardsson21-Sep-05 9:25 
Questionwhere to define &quot;Enable3dControlsStatic();&quot; Pin
valerie9919-Sep-05 5:34
valerie9919-Sep-05 5:34 
AnswerRe: where to define &quot;Enable3dControlsStatic();&quot; Pin
David Crow19-Sep-05 7:40
David Crow19-Sep-05 7:40 
AnswerRe: where to define &quot;Enable3dControlsStatic();&quot; Pin
Michael Dunn19-Sep-05 16:03
sitebuilderMichael Dunn19-Sep-05 16:03 
GeneralRe: where to define &quot;Enable3dControlsStatic();&quot; Pin
David Crow21-Sep-05 3:36
David Crow21-Sep-05 3:36 
GeneralRe: where to define &quot;Enable3dControlsStatic();&quot; Pin
Michael Dunn22-Sep-05 6:15
sitebuilderMichael Dunn22-Sep-05 6:15 
GeneralRe: where to define &quot;Enable3dControlsStatic();&quot; Pin
David Crow22-Sep-05 6:59
David Crow22-Sep-05 6:59 
GeneralRe: where to define &quot;Enable3dControlsStatic();&quot; Pin
Michael Dunn22-Sep-05 7:10
sitebuilderMichael Dunn22-Sep-05 7:10 
NewsNetworking Pin
sebastianos19-Sep-05 4:51
sebastianos19-Sep-05 4:51 
Question[Message Deleted] Pin
valerie9919-Sep-05 4:45
valerie9919-Sep-05 4:45 
AnswerRe: The one and only object been double defined Pin
MailtoGops19-Sep-05 4:59
MailtoGops19-Sep-05 4:59 
Generalthanks, the Dlg is not getting value Pin
valerie9919-Sep-05 5:28
valerie9919-Sep-05 5:28 
GeneralRe: thanks, the Dlg is not getting value Pin
David Crow19-Sep-05 7:43
David Crow19-Sep-05 7:43 
Generalthe more of CSurchrgDlg Pin
valerie9919-Sep-05 10:36
valerie9919-Sep-05 10:36 
GeneralRe: the more of CSurchrgDlg Pin
David Crow19-Sep-05 10:42
David Crow19-Sep-05 10:42 

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.