matlab isempty for std :: vector(c ++)

时间:2012-08-30 18:00:59

标签: c++ matlab stl

实现类似matlab函数检查std :: vector是否为空的最有效方法是什么?

这是我想要的示例代码

for (int i = 0; i<N; i++) {
    tmp = x[i];
    if ((tmp > max) || (tmp < max)) {
        indexout.push_back(tmp);
    }

    if ((tmp < min) && (tmp > max)) {
        indexin.push_back(tmp);
    }
}

if (isempty(indexin)) {   //heres the part i don't know how to do
    //do something
}
else

1 个答案:

答案 0 :(得分:6)

使用vector::empty()

if(indexin.empty()) {
}