#if 0
#include<iostream>
#include<list>
#include<map>
using namespace std;
int main()
{
list<int> list_test1;
list<int> list_test2(5);
list<int> list_test3(5, 2);
list<int> list_test4(list_test1);
list<int> list_test5(list_test1.begin(), list_test1.end());
list_test1.push_back(10);
list_test1.push_back(20);
list_test1.push_back(30);
list_test1.reverse();
list_test1.sort();
list_test1.push_front(80);
list_test1.push_front(90);
list_test1.pop_front();
list_test1.clear();
list_test2.clear();
list_test1.push_back(3);
list_test1.push_back(6);
list_test2.push_back(2);
list_test2.push_back(4);
list_test1.merge(list_test2);
list_test1.push_back(4);
list_test1.push_back(4);
list_test1.push_back(4);
list_test1.remove(4);
list_test1.remove_if([](int x){return x % 2 == 0; });
list_test1.push_back(4);
list_test1.push_back(4);
list_test1.push_back(4);
list_test1.push_back(4);
list_test1.push_back(2);
list_test1.push_back(2);
list_test1.unique();
}
#endif
#if 0
#include<iostream>
#include<deque>
using namespace std;
int main()
{
deque<double> deu_test1;
deque<double>::iterator it;
deque<double>::iterator it1;
}
#endif
头文件:#include"mylist.h"
#pragma once
template<typename _Tonde>
struct __list_node
{
typedef void* void_pointer;
void_pointer next;
void_pointer prev;
_Tonde date;
};
template<class T,class Ref,class Ptr>
struct __list_iterator
{
typedef __list_iterator<T, T&, T*> iterator;
typedef __list_iterator<T,const T&,const T*> const_iterator;
typedef __list_iterator<T, Ref, Ptr> self;
typedef std::bidirectional_iterator_tag iterator_category;
typedef T value_type;
typedef Ref reference;
typedef Ptr pointer;
typedef __list_node<T>* link_type;
typedef size_t size_type;
typedef ptrdiff_t differebce_type;
link_type node;
__list_iterator() :node();
__list_iterator(link_type x) :node(x){};
__list_iterator(const iterator& x) :node(x.node){};
bool operator==(const self& x)const{ return node == x.node; }
bool operator!=(const self& x)const{ return node != x.node; }
reference operator*()const{ return (*node).data; }
pointer operator->()const{ return &operator*(); }
self&operator++()
{
node = (link_type)(*node).next;
return *this;
}
self&operator++(int)
{
self tmp = *this;
++*this;
return tmp;
}
self&operator--()
{
node = (link_type)(*node).prev;
return *this;
}
self&operator--(int)
{
self tmp = *this;
--*this;
return tmp;
}
};
template <typename _Ty, class _ALLOC = std::allocator<_Ty>>
class Mylist
{
protected:
typedef __list_node<_Ty>list_node;
public:
typedef __list_node* link_type;
protected:
link_type node;
};