Linked list (list) in the Standard Template Library

Source: Internet
Author: User

C + + data Structures and Algorithms (4th edition) Adam Drozdek Diana Wu Weimin << Tsinghua University Press >>

Header file:include<list>

list () Create an empty list

List (size_type N, const t& el=t ()) creates a linked list that contains n copies of El

List (iterator first, Itsrator last) creates a linked list that contains the elements within the scope of the iterator first and previous

list (const list<t>& LST) copy constructor

void Assign (iterator first, iterator last) deletes all nodes in the linked list and inserts the elements in the range indicated by the iterator first and last

void Assign (size_type N, el Const t& el=t ()) deletes all nodes in the linked list and inserts n copies of El (using the default constructor T () If no El is provided)

t& back () returns the element in the last node of the list

const t& Back () const Returns the element in the last node of the linked list

iterator begin () returns an iterator that refers to the first node in a linked list

iterator End () returns an iterator that points to the position after the last node in the list

const_iterator begin () const Returns an iterator referencing the first node in a linked list

Const_iterator End () const Returns an iterator that points to the position after the last node in the list

void Clear () deletes all nodes in the linked list

bool Empty () const Returns True if the linked list does not contain elements, otherwise false

iterator Erase (iterator i) deletes the node referenced by the iterator I, returning an iterator that points to the element after the deleted node

t& Front () returns the elements from the first node in the list

Const t& Front () const Returns the elements from the first node in the linked list

iterator Insert (iterator I, const t& el=t ()) inserts an El into the node referenced by the iterator I, and returns an iterator that references the new node

void Insert (iterator I, Size_type n,const t& el) inserts n copies of El before the node referenced by the iterator I

void Insert (iterator I, iterator first,iterator last) inserts an element from the first to previous position before the node referenced by the iterator I

size_type max_size () const Returns the maximum number of nodes in a linked list

void Merge (list<t>& lst) for ordered tables and LST, removing all nodes from LST and inserting them into the current linked list in an orderly manner

void Merge (list<t>& lst, Com PF) to the ordered list and LST, remove all nodes from the LST and insert them into the current linked list in the order specified by function f ()

void Pop_back () deletes the last node of the linked list

void Pop_fornt () deletes the first node of a linked list

void Push_back (constt& el) inserts El at the end of the chain

void push_fornt (const t& EL) inserts the El in the chain header

void Remove (const t& EL) removes all nodes containing El from the linked list

void remove_if (Pred f) removes the node that causes the Boolean function f to return True, and F () has a parameter

void Resize (size_type n,const t& el=t ()) adds a n-size () node that contains the El of the element, or removes an extra size ()-n node from the tail of the linked list, making the list n nodes

void reverse () reverse linked list

reverse_iterator rbegin () returns an iterator that references the last node in the linked list

const_reverse_iterator rbegin () const Returns an iterator that references the last node in the linked list

reverse_iterator rend () returns an iterator that precedes the first node in the list

const_reverse_iterator rend () const Returns an iterator that precedes the first node in the list

size_type size () const Returns the number of nodes in the linked list

void sort () arranges the elements in the linked list in ascending order

void sort (Comp f) sorts the elements in the linked list in the order specified by the single-parameter Boolean function f ()

Void Splice (iterator I, list<t>& lst,iterator j) removes the node referenced by the iterator J from the list LST and inserts it into the position referenced by the iterator I

void Splice (iterator I, list<t>& lst, iterator first, iterator last) removes from the linked list LST the nodes within the range of the iterator first and last point, and insert it before the position referenced by the iterator I

void Swap (list<t>& lst) exchanges the contents of a linked list with the contents of another list LST

void Unique () removes duplicate elements from an ordered list

void Unique (Comp f) removes the repeating element specified by the Boolean function f () from the ordered list, and F () has two parameters

Return to C + + STL

Linked list (list) in the Standard Template Library

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.