入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

【C++】判断两个vector是否相等~直接用“==”

创建时间:2016-09-09 投稿人: 浏览次数:5397
  • 如果vector里面的元素类型是简单类型(内置类型),可以直接使用“==”或者“!=”进行比较
因为在STL里面,==和!=是可以直接使用的:
template< class T, class Alloc >
bool operator==( const vector<T,Alloc>& lhs,
                 const vector<T,Alloc>& rhs );

template< class T, class Alloc >
bool operator!=( const vector<T,Alloc>& lhs,
                 const vector<T,Alloc>& rhs );
  • 甚至可以使用“<=” “<” “>=” “>”比较两个vector大小:按照字典序排列
template< class T, class Alloc >
bool operator<( const vector<T,Alloc>& lhs,
                const vector<T,Alloc>& rhs );

template< class T, class Alloc >
bool operator<=( const vector<T,Alloc>& lhs,
                 const vector<T,Alloc>& rhs );

template< class T, class Alloc >
bool operator>( const vector<T,Alloc>& lhs,
                const vector<T,Alloc>& rhs );

template< class T, class Alloc >
bool operator>=( const vector<T,Alloc>& lhs,
                 const vector<T,Alloc>& rhs );
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。