C ++ list

Source: Internet
Author: User

The list stores elements in the linked list sequentially. Compared with the vector, the list allows fast insertion and deletion, but random access is slow.

Member functions
(Constructor)
Construct list (public member function) // Construct a linked list, list <int> L;
(Destructor)
List destructor (public member function)
Operator =
Copy container content (public member function) // you can assign values between linked lists <int> a, B
A = B;

Iterators:
Begin
Return iterator to beginning (public member function) // header. L. begin ().
End
Return iterator to end (public member function) // the end of the table + 1 L. end ();
Rbegin
Return reverse iterator to reverse beginning (public member function) // the end of the table L. rbegin ().
Rend
Return reverse iterator to reverse end (public member function) // header L. rend ();

Capacity:
Empty
Test whether container is empty (public member function) // checks whether the linked list is empty.
Size
Return size (public member function) // returns the size of the linked list.
Max_size
Return maximum size (public member function) // returns the maximum value of the linked list.
Resize
Change size (public member function) // reset the linked list size

Element access:
Front
Access first element (public member function) // retrieves the header
Back
Access last element (public member function) // obtain the end of the table

Modifiers:
Assign
Assign new content to container (public member function) // Assign length, Value
Push_front
Insert element at beginning (public member function) // Insert data in the queue Header
Pop_front
Delete first element (public member function) // The team header is displayed.
Push_back
Add element at the end (public member function) // Insert at the end of the team
Pop_back
Delete last element (public member function) // The team end element is displayed.
Insert
Insert elements (public member function) // Insert an element
Erase
Erase elements (public member function) // deletes an element.
Swap
Swap content (public member function) // Swap the length and values of different linked lists
Clear
Clear content (public member function) // Clear the linked list

Operations:
Splice
Move elements from list to list (public member function) // you can see the merging of linked lists.
Remove
Remove elements with specific value (public member function) // remove the specified element list. Remove (20); // remove
Remove_if
Remove elements fulfilling condition (public member function template) // can be overloaded to Remove elements in the specified range. Bool single_digit (const int & value) {return (value <10 );}
List. remove_if (single_digit );
Unique
Remove duplicate values (member function) // clear the 'identical 'elements in the linked list. Here, the same elements can also be overloaded .. For example
Bool same_integral_part (double first, double second)
{Return (int (first) = int (second ));}
List. unique (same_integral_part );
Merge
Merge sorted lists (public member function) // Merge two linked lists. If the two linked lists are ordered, the merged linked lists are also ordered. If there is no order, the l1 linked list is followed by l2
Sort
Sort elements in container (public member function) // sorts chat tables and can also be overloaded.
Reverse
Reverse the order of elements (public member function) // flip the linked list

Allocator:
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.