向量<> :: maxsize()的最大尺寸是多少? [英] 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<>.
我必须将百万条记录从一个向量<>复制到另一个向量<> ;,然后对该向量进行排序并应用我的过滤器函数(唯一id)来检索该记录。
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.
在向量中是可能的
尊敬的,
Karthik
Regards, Karthik
推荐答案
向量的最大大小是多少?
What is the maximum size of an vector ....
我想你已经回答了你自己的问题。
您可以使用函数向量< T> :: max_size()
获得的系统的理论极限。例如:
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.
然而在实践中,向量的分配数组必须在一个连续的内存块中,即使具有较小的内存分配也可能失败。如果你要使用向量的ints与百万元素我认为你不应该有任何问题。但是对于更大的对象,它可能会有问题。
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.
这篇关于向量<> :: maxsize()的最大尺寸是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!