home *** CD-ROM | disk | FTP | other *** search
- #ifndef __SIMPLELIST_H__
- #define __SIMPLELIST_H__
-
- class SimpleListNodeBase
- {
- protected:
- SimpleListNodeBase * next;
- SimpleListNodeBase * prev;
-
- void link( SimpleListNodeBase * start )
- {
- SimpleListNodeBase * nn = start->next;
- next = nn;
- if( nn )
- nn->prev = this;
- prev = start;
- start->next = this;
- }
- public:
- SimpleListNodeBase()
- : prev( 0 ),
- next( 0 )
- {}
- void unlink()
- {
- SimpleListNodeBase * pp = prev;
- SimpleListNodeBase * nn = next;
-
- pp->next = nn;
- if( nn )
- nn->prev = pp;
- prev = next = 0;
- }
- };
-
- template<typename T>
- class SimpleListNode : public SimpleListNodeBase
- {
- public:
- void link( SimpleListNode<T> * start )
- {
- SimpleListNodeBase::link( start );
- }
- T * get_next()const
- {
- return static_cast<T*>( next );
- }
- };
-
- #endif //__SIMPLELIST_H__