empty
语法:
1 |
bool empty() const; |
empty() 如果队列空则返回真
源代码
1 2 3 4 5 6 |
/** * Returns true if the %queue is empty. */ bool empty() const { return c.empty(); } |
测试代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
// 梁笔记 // https://zouzhongliang.com #include <iostream> #include <queue> using namespace std; int main() { queue<int> Qi; Qi.push(1); Qi.push(2); Qi.push(3); Qi.push(4); Qi.push(4); Qi.push(5); if (Qi.empty()) cout<<"队列是空的"<<endl; else cout<<"队列不是空的"<<endl; } |
测试结果
1 |
队列不是空的 |