A. List examples
#include <List> // call the system list, two-way circular linked list structure the using namespace STD; int main (void) { List < int > mylist; for ( int I = . 1 ; I <= 10 ; I ++ ) { mylist.push_back (I); // interfaces, added at the end } List < int > :: = mylist.begin IT iterator (); // iterator, the while (! IT = mylist.end ()) { COUT << << * IT " -> "; // print the internal digital
++ IT; } }
II. Source Learning
struct _Node;
typedef struct _Node * _Nodeptr; // pointer to type node
struct _Node {// _ Node is the node type
_Nodeptr _Prev; // precursor node
_Nodeptr _Next; // successor node
_Ty _Value; // template data types
};
struct _Acc {// definition of this type _ACC
typedef struct _Node * & _Nodepref; // pointer points to the node type of reference
typedef _Ty & _Vref; // This data type references
static _Nodepref _Next (_Nodeptr _P) // static method, returns the value of the reference node pointer is a pointer to the node parameters
{
return ((_Nodepref) (* _ P) ._ Next); //: * _ P obtained in this node, () cast priority is not high, so in this case to take -next, performing cast work, return. a node pointer pointing to a reference.
}
static _Nodepref _Prev(_Nodeptr _P)
{
return ((_Nodepref)(*_P)._Prev);
}
static _Vref _Value(_Nodeptr _P)
{
return ((_Vref)(*_P)._Value);}
};
public: // The following class types are the following types _A, _A class definition in the space of a divider
typedef typename _A::value_type value_type;
typedef typename _A::pointer_type pointer_type;
typedef typename _A::const_pointer_type const_pointer_type;
typedef typename _A::reference_type reference_type;
typedef typename _A::const_reference_type const_reference_type;
typedef typename _A :: size_type size_type; // this type is actually size_tprivate:
_Nodeptr _Head; // pointer pointing to the head node
III. Constructor and destructor
public:
explicit list (): _ Head (_Buynode ()), _ Size (0) // explicit display the constructor is called, pointing to a head, beginning 0
{}
~list()
{// free up space and space-related configurator, to not care at this stage.
erase (begin (), end ()); // call the start, the end of the function to release the space;
_Freenode (_Head); // release the head;
_Head = 0, _Size = 0; // null Ode;
}