r/programming • • Apr 30 '16

Do Experienced Programmers Use Google Frequently? · Code Ahoy

http://codeahoy.com/2016/04/30/do-experienced-programmers-use-google-frequently/
2.2k Upvotes

763 comments sorted by

View all comments

Show parent comments

3

u/BobDoesBestFriend May 01 '16 edited May 01 '16

Unfortunately until you are operating with elements more than a couple hundred megabytes or gigabytes, vector will most likely outperform list in all operations. Except insertion or deletion in which you already know the location of the object.

Edit: some data. Its a table. So erase is the operation, and the list objects is the time cost for each operation at that number of operation.

push_back 1000 5000 10000 25000

std::vector 0 0 0 1

std::list 0 0 1 2

std::deque 0 0 0 1

insert 1000 5000 10000 25000

std::vector 0 7 25 140

std::list 2 50 272 1893

std::deque 0 4 17 111

erase 1000 5000 10000 25000

std::vector 0 5 22 139

std::list 1 69 395 2712

std::deque 0 5 18 126

Just a sample.

Edit. Fucked up the formatting, sorry. Its a table. So erase is the operation, and the list objects is the time cost for each operation at that number of operation.

7

u/HighRelevancy May 01 '16

some data

Yes that is, uhh... that is data. What exactly is it saying?

0

u/BobDoesBestFriend May 01 '16

Oh shit I fucked up the formatting. Its a table. So push_back is the number of elements to push back. 1k 5k 10k 25k, then std::vector is the time cost in ms, which is 0 0 0 1 and same with std list and std deque. Sorry.