C ++ deque

Source: Internet
Author: User

Deque is a two-way queue.

The main operations for deque are:


(Constructor)
Construct deque container (Public member function) // construct deque
Format: deque <int> D;
Operator =
Copy container content (Public member function) // you can assign values between containers.
For example, deque <int> d1 (4,100), D2; d2 = D1; // D2 is equivalent to D1.
Begin
Return iterator to beginning (Public member function) // locate the start position of the container
End
Return iterator to end (Public member function) // The position with the highest value in the container + 1
Rbegin
Return reverse iterator to reverse beginning (Public member function) // find the team end
Rend
Return reverse iterator to reverse end (Public member function) // locate the team Header
Size
Return size (Public member function) // container size
Max_size
Return maximum size (Public member function) // The maximum number of elements that a container can hold.
Resize
Change size (Public member functions) // You can reset the container size and assign the elements that are not assigned a value to the specified value.
Empty
Test whether container is empty (Public member function) // checks whether the container is empty.
OPERATOR []
Access element (Public member function) // reload []... for usage like an array
At
Access element (Public member function) // similar to the overload [], you can assign a value D. at (I) = I; // you can assign a value like this
Front
Access first element (Public member function) // obtain the value before the queue. D. Front ();
Back
Access last element (Public member function) // obtain the value after the queue. D. Back ();
Assign
Assign container content (Public member function) // allocate the container size and value D. Assign (4,100)
The allocated container size is 4 and the value is 100
Push_back
Add element at the end (Public member function) // Insert the value to the end of the queue
Push_front
Insert element at beginning (Public member function) // Insert the value to the queue header.
Pop_back
Delete last element (Public member function) // returns the value at the end.
Pop_front
Delete first element (Public member function) // bring up the value of the queue Header
Insert
Insert elements (Public member function) // insert a value. Insert the specified value at the specified position, and the value after it is removed .. For example, D. insert (it, 100) can also insert 2 (n) 100, D. insert (it, 2,100 ).
Erase
Erase elements (Public member function) // deletes the value of a specified position and interval.
Swap
Swap content (Public member function) // exchange between containers, including the container size and values in the container, such as d1.swap (D2 );
Clear
Clear content (Public member function) // clear the container
Get_allocator
Get Allocator (Public member function)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.