Use of STL controls

Source: Internet
Author: User

1. List using:

The doubly linked list of data structures generally corresponds to the list in the STL, and List provides almost all the methods for double-linked list operations

Common list operations are (at least I use):

Remove

Push_back,

</pre><pre name= "code" class= "CPP" > #include <iostream> #include <list>using namespace std; struct Node{int key;int val;}; void Main () {node * nn;list<node*> ll;for (int i=0; i<5; i++) {node * tmp=new node;tmp->key=i;ll.push_back (TMP) ; if (i==3) nn=tmp;} Ll.remove (NN); List<node*>::iterator it;cout<< "All the data in the list is:" <<endl;for (It=ll.begin () ; It!=ll.end (); it++) {cout<< (*it)->key<<endl;} cout<<endl<< "After delete the node the original pointer's space is still exist" <<endl;cout<<nn-& gt;key<<endl<<endl;cout<< "ll ' s size is:" <<ll.size () <<endl;}

Operation Result:


Use of STL controls

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.