assign
语法:
1 2 |
void assign( input_iterator start, input_iterator end); void assign( Size num, const TYPE &val ); |
assign()函数用start和end指示的范围为双向队列赋值,或者设置成num个val。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
源代码 /** * @brief Assigns a given value to a %deque. * @param n Number of elements to be assigned. * @param val Value to be assigned. * * This function fills a %deque with @a n copies of the given value. * Note that the assignment completely changes the %deque and that the * resulting %deque's size is the same as the number of elements assigned. * Old data may be lost. */ void assign(size_type __n, const value_type& __val) { _M_fill_assign(__n, __val); } /** * @brief Assigns a range to a %deque. * @param first An input iterator. * @param last An input iterator. * * This function fills a %deque with copies of the elements in the * range [first,last). * * Note that the assignment completely changes the %deque and that the * resulting %deque's size is the same as the number of elements * assigned. Old data may be lost. */ template<typename _InputIterator> void assign(_InputIterator __first, _InputIterator __last) { typedef typename _Is_integer<_InputIterator>::_Integral _Integral; _M_assign_dispatch(__first, __last, _Integral()); } |
测试代码:
测试结果:
dq3双向对列:
0 0 0 0 0 0 0 0 0 0
dq2双向对列:
88 88 88 88 88 88 88 88 88 88
请按任意键继续. . .
《双向队列assign函数运用》上有1条评论
评论已关闭。