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 #include <w_base.h>
00035 #include <w_list.h>
00036
00037
00038 void
00039 w_link_t::attach(w_link_t* prev_link)
00040 {
00041 w_assert2(_prev == this && _next == this);
00042 _list = prev_link->_list;
00043 _next = prev_link->_next;
00044 _prev = prev_link;
00045 prev_link->_next = this;
00046 _next->_prev = this;
00047 ++(_list->_cnt);
00048 }
00049
00050 w_link_t*
00051 w_link_t::detach()
00052 {
00053 if (_next != this) {
00054 w_assert2(_prev != this);
00055 _prev->_next = _next, _next->_prev = _prev;
00056 _list->_cnt--;
00057 w_assert2(_list->_cnt ||
00058 (_list->_tail._prev == & _list->_tail &&
00059 _list->_tail._next == & _list->_tail));
00060 _next = _prev = this, _list = 0;
00061 }
00062 return this;
00063 }
00064
00065 ostream&
00066 operator<<(ostream& o, const w_link_t& n)
00067 {
00068 o << "_list = " << n.member_of() << endl;
00069 o << "_next = " << n.next() << endl;
00070 o << "_prev = " << n.prev();
00071 return o;
00072 }
00073
00074 void
00075 w_list_base_t::dump()
00076 {
00077 cout << "_tail = " << _tail << endl;
00078 cout << "_cnt = " << _cnt << endl;
00079 cout << "_adj = " << _adj << endl;
00080 }
00081