Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Please specify the range of vector list ....

I want to store million of records in vector<>.

I have to copy Millions of records from one vector<> to another vector<> and then sort the vector and apply my filter function(unique id) to retrieve the record.

is this possible in vector

Regards, Karthik

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

What is the maximum size of an vector ....

I think you have answered your own question. Theoretical limit for your system you can get with a function vector<T>::max_size(). For instance:

vector<int> vec;
std::cout<<vec.max_size()<<std::endl;//prints max size for vector<int> in your system!

So just run this and check out the answer for your system.

However in practice the vector's allocated array must be in one consecutive memory block and even with less size memory allocation can fail. If you are going to use vector of ints with million elements I think you shouldn't have any problems. However for bigger objects it can be problematic.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...