Click here to Skip to main content
16,006,749 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: STL vs. MFC Pin
lpvoid7-Jan-03 2:52
lpvoid7-Jan-03 2:52 
GeneralRe: STL vs. MFC Pin
valikac6-Jan-03 16:10
valikac6-Jan-03 16:10 
GeneralRe: STL vs. MFC Pin
lpvoid7-Jan-03 3:00
lpvoid7-Jan-03 3:00 
GeneralRe: STL vs. MFC Pin
valikac7-Jan-03 4:43
valikac7-Jan-03 4:43 
GeneralRe: STL vs. MFC Pin
lpvoid7-Jan-03 5:48
lpvoid7-Jan-03 5:48 
GeneralRe: STL vs. MFC Pin
valikac7-Jan-03 9:02
valikac7-Jan-03 9:02 
GeneralRe: STL vs. MFC Pin
User 98858-Jan-03 10:06
User 98858-Jan-03 10:06 
GeneralRe: STL vs. MFC Pin
User 98859-Jan-03 2:36
User 98859-Jan-03 2:36 
A thing to consider.

vector does not change its item count, if you do not use push_back or insert. Hence adding items with [] operator in a random manner after reserve is practically unusable.

But, CArray has a bigger problem. Once you do SetSize(), GetCount() always returns the size set by SetSize(). CArray is therefore a very close implementation to a C array, where as vector has a max_size and a size, max_size is the value you set with reserve. size represents the actual number of items you inserted into the vector.

Just observations that I made. Anyway, you can do the folllowing too, to speed up vector in your sample.

vector<int > vint;
vint.reserve(1000000);
int* p = &vint[0];

for (int i = 0; i < 1000000; ++i)
{
*(p + i) = i;
}

Using rand is also not correct. I would recommend leaving it out, because rand does not seem to be a constant time operation.


My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers


modified 29-Aug-18 21:01pm.

GeneralRe: STL vs. MFC Pin
Tim Smith9-Jan-03 4:04
Tim Smith9-Jan-03 4:04 
GeneralRe: STL vs. MFC Pin
User 98859-Jan-03 5:12
User 98859-Jan-03 5:12 
GeneralRe: STL vs. MFC Pin
Tim Smith9-Jan-03 15:08
Tim Smith9-Jan-03 15:08 
GeneralRe: STL vs. MFC Pin
lpvoid10-Jan-03 13:45
lpvoid10-Jan-03 13:45 
GeneralRe: STL vs. MFC Pin
lpvoid10-Jan-03 16:48
lpvoid10-Jan-03 16:48 
GeneralHelp with ATL 7.0 Pin
Binky6-Jan-03 8:12
Binky6-Jan-03 8:12 
Generalmap of _variant_t Pin
[James Pullicino]5-Jan-03 21:57
[James Pullicino]5-Jan-03 21:57 
GeneralRe: map of _variant_t Pin
Michael Dunn5-Jan-03 22:14
sitebuilderMichael Dunn5-Jan-03 22:14 
GeneralRe: map of _variant_t Pin
[James Pullicino]5-Jan-03 22:20
[James Pullicino]5-Jan-03 22:20 
GeneralRe: map of _variant_t Pin
Jörgen Sigvardsson17-Jan-03 12:26
Jörgen Sigvardsson17-Jan-03 12:26 
GeneralProblem with WTL Pin
Ph@ntom5-Jan-03 18:43
Ph@ntom5-Jan-03 18:43 
GeneralRe: Problem with WTL Pin
Michael Dunn5-Jan-03 20:40
sitebuilderMichael Dunn5-Jan-03 20:40 
GeneralRe: Problem with WTL Pin
User 98858-Jan-03 10:14
User 98858-Jan-03 10:14 
GeneralWTL: a newbie question Pin
Shah Shehpori5-Jan-03 18:41
sussShah Shehpori5-Jan-03 18:41 
GeneralRe: WTL: a newbie question Pin
Jörgen Sigvardsson17-Jan-03 12:29
Jörgen Sigvardsson17-Jan-03 12:29 
GeneralCRegKey QueryStringValue Pin
rbeckett5-Jan-03 17:01
rbeckett5-Jan-03 17:01 
GeneralRe: CRegKey QueryStringValue Pin
Michael Dunn5-Jan-03 17:24
sitebuilderMichael Dunn5-Jan-03 17:24 

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.