Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 15th, 2006, 6:17 PM   #21
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 822
Rep Power: 4 The Dark is on a distinguished road
Quote:
Originally Posted by grumpy
Accessing elements or appending to the end is fast (technically: constant). Inserting elements in is moderately fast (technically: linear with number of elements). Deletions from the middle are slow.
Inserting elements in the middle of a vector suffers the same problem as deleting elements from the middle - the rest of the vector has to be shuffled around - they are both slow.

Also, appending to the end of a vector may occasionally cause the whole vector to be reallocated and all of the items to be moved. This can be very bad, but using reserve() can help a bit.

std::deque containers are better for when you are continually adding to the end.
The Dark is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:17 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC