's last post goes directly to the problem I think.
IMO using a vector with millions of data is a bad idea, because it is very inefficient due to having to reallocate memory, despite the capacity strategy.
You might need a combination of types of containers. A vector might be fine for storing a combination or permutation of a limited size, but have a different one for storing all of them a
and others come to mind, but which which one depends on what you want to do exactly.
I have a question:
Is this for one of the on-line problem solving questions?
If so, then I would say that the solutions are not as trivial as they may seem. For example they limit the run time to 1 second, but a naive approach means processing factorial n combinations, which for a number that is larger than an unsigned 64 bit quantity might take your computer more than a minute to process. So you need to implement a smart algorithm that cuts down on unnecessary processing.
|What I would do is use a vector or deque like duoas said since he probably knows better but I haven't used one before but when I read up on it, it sounded almost identical.|
There are differences in the way various containers are implemented. For example, try to find out the differences between array, std::array, vector, list, set, map etc.