w_listm.cpp

00001 /*<std-header orig-src='shore'>
00002 
00003  $Id: w_listm.cpp,v 1.13 2010/12/08 17:37:37 nhall Exp $
00004 
00005 SHORE -- Scalable Heterogeneous Object REpository
00006 
00007 Copyright (c) 1994-99 Computer Sciences Department, University of
00008                       Wisconsin -- Madison
00009 All Rights Reserved.
00010 
00011 Permission to use, copy, modify and distribute this software and its
00012 documentation is hereby granted, provided that both the copyright
00013 notice and this permission notice appear in all copies of the
00014 software, derivative works or modified versions, and any portions
00015 thereof, and that both notices appear in supporting documentation.
00016 
00017 THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY
00018 OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS
00019 "AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND
00020 FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
00021 
00022 This software was developed with support by the Advanced Research
00023 Project Agency, ARPA order number 018 (formerly 8230), monitored by
00024 the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518.
00025 Further funding for this work was provided by DARPA through
00026 Rome Research Laboratory Contract No. F30602-97-2-0247.
00027 
00028 */
00029 
00030 #include "w_defines.h"
00031 
00032 /*  -- do not edit anything above this line --   </std-header>*/
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); // not in any list
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 

Generated on Mon Jan 2 15:13:57 2012 for Shore Storage Manager by  doxygen 1.4.7