push
语法:
1 |
void push(const value_type& __x); |
push() 在末尾加入一个元素
源代码
1 2 3 4 5 6 7 8 9 10 11 12 |
/** * @brief Add data to the end of the %queue. * @param x Data to be added. * * This is a typical %queue operation. The function creates an * element at the end of the %queue and assigns the given data * to it. The time complexity of the operation depends on the * underlying sequence. */ void push(const value_type& __x) { c.push_back(__x); } |
测试代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// 梁笔记 // 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(5); cout<<Qi.size()<<endl; } |
测试结果
1 |
5 |