源代码
G2.9 sizeof(list)=4 link_node * 一个指针在32位系统是4字节
G4.9 sizeof(list)=8
template<class T,class Alloc=alloc>
class list{
protected:
typedef _list_node<T> list_node;
public:
typedef list_node* link_type;
typedef _list_iterator<T,T&,T*> iterator;//模拟指针
protected:
link_type node;
......
};
template <class T>
struct _list_node{
typedef void* void_pointer;
void_pointer prev;//指向void 这种指针,需要正确的转型
void_pointer next;
T data;
};
template<class T,class Ptr>
struct _list_iterator{
typedef T value_type;
typedef Ptr pointer;
typedef Ref reference;
};
//需要自动进入查看next和pre指针,当++就智能的查看next
灰色的结点是为了实现前闭后开区间
迭代器
//G2.9
template<class T,class Ptr