00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 #include "w_defines.h"
00031 
00032 
00033 
00034 #define W_SOURCE
00035 #include <w_base.h>
00036 #include <w_list.h>
00037 
00038 
00039 void
00040 w_link_t::attach(w_link_t* prev_link)
00041 {
00042     w_assert2(_prev == this && _next == this); 
00043     _list = prev_link->_list;
00044     _next = prev_link->_next; 
00045     _prev = prev_link;
00046     prev_link->_next = this;
00047     _next->_prev = this;
00048     ++(_list->_cnt);
00049 }
00050 
00051 w_link_t*
00052 w_link_t::detach()
00053 {
00054     if (_next != this)  {
00055         w_assert2(_prev != this);
00056         _prev->_next = _next, _next->_prev = _prev;
00057         _list->_cnt--;
00058         w_assert2(_list->_cnt ||
00059                (_list->_tail._prev == & _list->_tail &&
00060                 _list->_tail._next == & _list->_tail));
00061             _next = _prev = this, _list = 0;
00062     }
00063     return this;
00064 }
00065 
00066 ostream&
00067 operator<<(ostream& o, const w_link_t& n)  
00068 {
00069     o << "_list = " << n.member_of() << endl;
00070     o << "_next = " << n.next() << endl;
00071     o << "_prev = " << n.prev();
00072     return o;
00073 }
00074 
00075 void
00076 w_list_base_t::dump()
00077 {
00078     cout << "_tail = " << _tail << endl;
00079     cout << "_cnt = " << _cnt << endl;
00080     cout << "_adj = " << _adj << endl;
00081 }
00082