1// Compatibility symbols for previous versions, list bits -*- C++ -*- 2 3// Copyright (C) 2010 Free Software Foundation, Inc. 4// 5// This file is part of the GNU ISO C++ Library. This library is free 6// software; you can redistribute it and/or modify it under the 7// terms of the GNU General Public License as published by the 8// Free Software Foundation; either version 3, or (at your option) 9// any later version. 10 11// This library is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14// GNU General Public License for more details. 15 16// Under Section 7 of GPL version 3, you are granted additional 17// permissions described in the GCC Runtime Library Exception, version 18// 3.1, as published by the Free Software Foundation. 19 20// You should have received a copy of the GNU General Public License and 21// a copy of the GCC Runtime Library Exception along with this program; 22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23// <http://www.gnu.org/licenses/>. 24 25#include <bits/move.h> 26 27_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) 28 29 struct _List_node_base 30 { 31 _List_node_base* _M_next; 32 _List_node_base* _M_prev; 33 34 void 35 transfer(_List_node_base * const __first, 36 _List_node_base * const __last) throw (); 37 38 void 39 reverse() throw (); 40 41 void 42 hook(_List_node_base * const __position) throw (); 43 44 void 45 unhook() throw (); 46 }; 47 48 void 49 _List_node_base::transfer(_List_node_base * const __first, 50 _List_node_base * const __last) throw () 51 { 52 if (this != __last) 53 { 54 // Remove [first, last) from its old position. 55 __last->_M_prev->_M_next = this; 56 __first->_M_prev->_M_next = __last; 57 this->_M_prev->_M_next = __first; 58 59 // Splice [first, last) into its new position. 60 _List_node_base* const __tmp = this->_M_prev; 61 this->_M_prev = __last->_M_prev; 62 __last->_M_prev = __first->_M_prev; 63 __first->_M_prev = __tmp; 64 } 65 } 66 67 void 68 _List_node_base::reverse() throw () 69 { 70 _List_node_base* __tmp = this; 71 do 72 { 73 std::swap(__tmp->_M_next, __tmp->_M_prev); 74 75 // Old next node is now prev. 76 __tmp = __tmp->_M_prev; 77 } 78 while (__tmp != this); 79 } 80 81 void 82 _List_node_base::hook(_List_node_base* const __position) throw () 83 { 84 this->_M_next = __position; 85 this->_M_prev = __position->_M_prev; 86 __position->_M_prev->_M_next = this; 87 __position->_M_prev = this; 88 } 89 90 void 91 _List_node_base::unhook() throw () 92 { 93 _List_node_base* const __next_node = this->_M_next; 94 _List_node_base* const __prev_node = this->_M_prev; 95 __prev_node->_M_next = __next_node; 96 __next_node->_M_prev = __prev_node; 97 } 98 99_GLIBCXX_END_NESTED_NAMESPACE 100