摘要: 一般写法,但容易导致值溢出 left + right这步操作有可能导致 int 溢出 int left = 0, right = n, mid; mid = (left + right) / 2; 防止值溢出写法 left加上right减去left差值的一半绝对比left + right安全的多 i 阅读全文
posted @ 2022-10-15 10:27 jessicaland 阅读(112) 评论(0) 推荐(0)
摘要: 1 //文字节点 2 std::vector<GeometricPrimitives*> GP = _dwgData["Axis"]; 3 osg::ref_ptr<osg::Geode> currentLabel = GP->getCurrentLabel(); 4 osg::ref_ptr<os 阅读全文
posted @ 2022-09-22 17:32 jessicaland 阅读(213) 评论(0) 推荐(0)
摘要: 关联式容器multimap与map相似。 multimap 容器具有和 map 相同的特性,即 multimap 容器也用于存储 pair<const K, T> 类型的键值对(其中 K 表示键的类型,T 表示值的类型),其中各个键值对的键的值不能做修改;并且,该容器也会自行根据键的大小对存储的所有 阅读全文
posted @ 2022-08-25 15:52 jessicaland 阅读(171) 评论(0) 推荐(0)
摘要: STL中的容器按存储方式分为两类:一类是序列容器(如:vector,deque),另一类是关联容器(如:list,map,set)。 (1)对于关联容器(如map,set,multimap,multiset),删除当前的iterator,仅仅会使当前的iterator失效,只要在erase时,递增当 阅读全文
posted @ 2022-08-24 09:21 jessicaland 阅读(414) 评论(0) 推荐(0)
摘要: continue continue语句用于循环语句中,作用是不执行循环体剩余部分,直接进行下次循环。 常见的就是与if连用。 比如下面这个程序: 1 int main() 2 { 3 int i; 4 for(i = 0; i < 10; i ++) 5 { 6 if(i%2==0) continu 阅读全文
posted @ 2022-08-24 09:17 jessicaland 阅读(702) 评论(0) 推荐(0)
摘要: 同理, continue<break continue--退出当次while,会接着从while循环的开始部分重新执行下来, break--退出while循环,但while循环后面还有其他语句的话,还是会执行 阅读全文
posted @ 2022-08-24 09:15 jessicaland 阅读(90) 评论(0) 推荐(0)
摘要: 正向迭代器: map<int, int>::iterator mit; 反向迭代器: map<int, int>::reverse_iterator rit; 两者相差一个元素,从一个反向迭代器获得对应的正向迭代器需要使用 base() 方法。如下图所示:ri 是指向元素3的反向迭代器,而 i 是 阅读全文
posted @ 2022-08-23 16:09 jessicaland 阅读(142) 评论(0) 推荐(0)
摘要: 版本回退:Update to revision... 最新版本:Head revision 阅读全文
posted @ 2022-08-23 14:54 jessicaland 阅读(25) 评论(0) 推荐(0)
摘要: 1 //在map中插入map的值: 2 #include <map> 3 #include <iostream> 4 int main() { 5 std::map<int, int>a,b,c; 6 a.insert({ 1,1 }); 7 a.insert({ 2,2 }); 8 //复制第一组 阅读全文
posted @ 2022-08-20 10:21 jessicaland 阅读(81) 评论(0) 推荐(0)
摘要: etc is a written abbreviation for (书面缩略=) 'et cetera'. 阅读全文
posted @ 2022-08-19 17:38 jessicaland 阅读(30) 评论(0) 推荐(0)