I am not really doing operations on the vector, I am just storing values and retrieving them later. The problem is there are just lots and lots of them.
How are you retrieving them? Is it in linear order or some kind of search? A straight traversal from beginning to end or end to beginning is well suited for an array, but you probably won't see a big difference between an array and a vector in that case. The storage overhead for a vector will be overwhelmed right away by the values, and the runtime cache difference between an array and a vector will be nonexistent.
If you're searching for values, the time you spend paging cache lines in and out is probably going to be significant with lots and lots of values, so a structure designed for searching like a set or hash_set should be your first step in optimizing the performance.
don't I have to then manually delete the variable when I'm done with it?
Yes, if you manually allocate memory, you have to manually delete it.
Also, how can you get the length of the array after the fact (ie. the equivalent of MyVector.size() )?
If it's an actual array you can divide the size of the array as a whole by the size of a single element to get the number of elements:
#include <iostream>
int main()
{
int a[100];
// Prints 100
std::cout << sizeof a / sizeof a[0] << '\n';
}
If all you have is a pointer, you have to rely on passing around the size as a separate entity. Or you can wrap the whole thing in an object so that it has a size() method, just like the vector class.