2012-08-30 58 views
0

什么是最有效的方式来实现一个matlab函数来检查std :: vector是否为空?matlab的isempty为std :: vector(C++)

这里有什么,我想

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 
+2

'std :: vector' already * has *'empty()'函数。那有什么问题? – jalf

+2

请参阅[这里](http://en.cppreference.com/w/cpp/container/vector)。 – juanchopanza

回答

6

使用vector::empty()一个示例代码。

if(indexin.empty()) { 
} 
+0

不知道这存在的感谢! – pyCthon

+0

http://jcatki.no-ip.org/fncpp/cplusplus.com – 2012-08-31 22:08:23

相关问题