#include <iostream>
#include <list>
using namespace Std;
Standard classes are stored in a two-way circular list
List class
1 classList2 {3 list ();4ListintNConstT&value=T ());5List (T *first,t *Last );6 //push_back ();7 //Pop_back ();8 //size ();9 //The above method is the same as the vector list also containsTen voidPush_front (Constt&value); One voidPop_front (); A -Iterator begin ();//Iterators point to the first node by default -Iterator End ();//point to table header the - voidErase (iterator POS); - voidErase (iterator first,iterator last);//Delete Interval -Iterator Insert (iterator POS,ConstT&value);//plug in front of POS +}
Iterator (STL Universal)
*iter; Value pointing to the node
iter++; Point to Next
iter--;
Iter1==iter2; Point to the same location
*iter1==*iter2; A value equal position is not necessarily
Instantiation:
Std::list<int>::iterator Iter=list.begin ();
Delete (! ):
List.erase (iter++); Note + + Otherwise the table after the delete node loses memory leaks
Here the + + operator overload first gets the next node position and then delete if ++iter then delete and get the next position
Insert Exercise:
void Doubledata (std::list <T> &alist)
{
Std::list<t>::iterator P=alist.begin ();
while (P!=alist.end ())
{
Alist.insert (P,*P);
p++;
}
}
Initial data: 1234 Output results: 11223344
Data Structure-table (list)