quicker for inserts

This is a discussion on quicker for inserts within the C++ Programming forums, part of the General Programming Boards category; i have a list of what will be about 12000 values of type short. currently im using a vector..but the ...

  1. #1
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455

    quicker for inserts

    i have a list of what will be about 12000 values of type short. currently im using a vector..but the test program is only about 100 values. is it significantly faster to use arrays or vectors? vectors are much easier to handle. the mainly operation will be inserting the values and retriving them, not many other operations will be done on them until theyre inserted into a matrix type thing, that im not sure of yet though.

    any thoughts?

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,799
    Use the vector and just make sure you reserve the necessary space for the number of items you expect prior to adding elements to the vector. That will make things quicker, eliminating any need for internal reallocation of memory.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    well depends on wheather u will be accessing the data from the end , middle, inserting at back or middle etc etc..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Is there a quicker way to initialise an array?
    By webznz in forum C Programming
    Replies: 5
    Last Post: 10-25-2007, 03:45 AM
  2. Why a quicker shutdown?
    By Yarin in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 10-02-2007, 04:45 PM
  3. quicker access to structmembers?
    By darksaidin in forum C++ Programming
    Replies: 14
    Last Post: 07-29-2003, 09:14 AM
  4. What is Quicker
    By Nor in forum Game Programming
    Replies: 3
    Last Post: 02-02-2002, 03:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21