std::set::迭代器的大小有限制吗
Is there a limit on the size of std::set::iterator?
我有一个std::字符串集,我想对它们进行迭代,但迭代器对不同大小的字符串集的行为不同。下面是我正在处理的代码片段:
int test(set<string> &KeywordsDictionary){
int keyword_len = 0;
string word;
set<string>::iterator iter;
cout << "total words in the database : " << KeywordsDictionary.size() << endl;
for(iter=KeywordsDictionary.begin();iter != KeywordsDictionary.end();iter++) {
cout << *iter;
word = *iter;
keyword_len = word.size();
if(keyword_len>0)
Dosomething();
else
cout << "Length of keyword is <= 0" << endl;
}
cout << "exiting test program" << endl;
}
代码工作正常&CCD_ 1正在被取消引用&分配给CCD_ 2,直到CCD_。然而,当KeywordsDictionary
的大小增加到15000以上时,
- 打印语句CCD_ 5正在正确地打印CCD_
- 但是指向迭代器CCD_ 7的指针没有被取消引用&不被分配给CCD_ 8。
word
只是一个空字符串
编辑:程序的输出为:
total words in the database : 22771
�z���AAAADAAIIABABBABLEABNABOUTACACCEPTEDACCESSACCOUNT...
Length of keyword is <= 0
exiting test program
所以基本上,我猜这个循环只执行一次。
尝试将关键字_len声明为
std::string::size_type keyword_len = 0;
而不是
int keyword_len = 0;
相关文章:
- 在程序变得低效之前,允许多少新的[]和删除[]分配是否有限制?
- 对同一文件使用 .read 的次数是否有限制?
- 有条件的打印和计数在 std::map 上有限制
- arduino count++ 是否有限制以及如何修复它?
- 创建的事件数量是否有限制?
- 在SFML中,时钟有限制吗?
- 在mbed中打开的wav文件数量是否有限制
- C++中无序集的大小是否有限制
- 是否对在另一个Linux发行版中使用G 编译的可执行文件有限制
- 这个程序有限制吗?
- std::set::迭代器的大小有限制吗
- 递归是否有限制
- 可以在 CUDA 中使用的数组大小是否有限制
- 使用 SB_SETTEXT 的状态栏中显示的字符数是否有限制
- 在matlab上生成有限制的随机向量时出现问题
- Q设置:.ini文件的行长度有限制吗
- 在Main.cpp中包含头文件有限制吗?
- 访问者模式与对输入类型有限制的向下转换
- cin.有限制地忽略,继续丢弃新的输入
- c++中标识符名称的长度是否有限制?