码迷,mamicode.com
首页 > 编程语言 > 详细

set C++容器

时间:2014-12-19 00:23:08      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   sp   for   on   div   log   bs   

1.如何判断set加入的值是否重复

    // 举例如下:
    int a[] = {1,2,3,4,5,6,7,8,1,2};
    int nSize = sizeof(a)/sizeof(a[0]);
    using namespace std;
    set<int> sint;
    for(int i=0; i<nSize; ++i)
    {
        pair<set<int>::iterator,bool> result = sint.insert(i);
        if(result.second == false) // 插入的值重复,返回false
        {
            // do something
        }
    }

 

set C++容器

标签:style   blog   color   sp   for   on   div   log   bs   

原文地址:http://www.cnblogs.com/sylar-liang/p/4172899.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!