//
@丿小夕vetemplate < typename InType, typename T = cov::handler < InType > >class cov::list
{
protected:
class node
{
friend class list;
friend class iterator;
T data;
node *front = 0;
node *behind = 0;
};
public:
class iterator
{
friend class list;
protected:
node * me;
public:
iterator():me(0)
{
}
iterator(node * ptr):me(ptr)
{
}
iterator(const iterator &) = default;
operator bool() const
{
return me;
}
T & operator*() const
{
if (me)
return me->data;
}
T *operator->() const
{
if (me)
return &me->data;
}
iterator & operator++()
{
me = me->behind;
return *this;
}
iterator & operator--()
{
me = me->front;
return *this;
}
bool operator==(const iterator & obj)
{
return me == obj.me;
}
bool operator!=(const iterator & obj)
{
return me != obj.me;
}
};
protected:
node * m_head;
node *m_end;
long m_size = 0;
public:
list():m_head(0), m_end(0)
{
}
list(const list & in);
~list();
void clear();
const list & operator=(const list & in);
void push_front(const T & obj);
void push_back(const T & obj);
void pop_front();
void pop_back();
void insert(iterator it, const T & obj);
void erase(iterator & it);
void remove(const T & obj);
long size() const
{
return m_size;
}
iterator head()
{
return list < InType, T >::iterator(m_head);
}
iterator tail()
{
return list < InType, T >::iterator(m_end);
}
};