Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
940 views
in Technique[技术] by (71.8m points)

c++ - What is the maximum size of an vector<>::maxsize()?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.6k users

...