So what is the difference between these types? Performance, ineffiency, what?
So what is the difference between these types? Performance, ineffiency, what?
Basically vectors are dynamic arrays which mean you can add or delete contents. With arrays you have to manage memory, vectors does this for you... Um basically you want to use vectors when you are going to either be deleting or adding items to the end. Use an array when you want to just store a set number of values, also if you're looking to add or delete items in the the middle of an array I believe it's more efficient to use lists (deque?) I'm not 100% postive about this because I myself am still learning.
Google returns a lot of info for this..
when to use each:
set number of data ----> array
dynamic number of data, adding/deleting at end -----> vector
dynamic number of data, adding/deleting in middle ---> lists
A vector is a dynamic array. An array is simply a static array. It has a fixed amount of elements. A vector will expand its size as necessary to accommodate new elements.
Vectors are generally your general choice container, unless you have special need.
If you're going to add/delete at the beginning, a deque might be good.
If you're going to add/delete in the middle, a linked list may be good.
I think one rather important difference is that a vector is a dynamically allocated array, that can be partially uninitialized (unused memory is not initialized).
When you allocate an array with new X[n] then exactly n objects will be created, no more, no less.
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Thanks guys.