Blender V2.61 - r43446

CTR_List.cpp

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #include "CTR_List.h"
00034 
00035 
00036 CTR_Link::
00037 CTR_Link(
00038 ) : 
00039     m_next(0), 
00040     m_prev(0) 
00041 {
00042 }
00043 
00044 CTR_Link::
00045 CTR_Link(
00046     CTR_Link *next,
00047     CTR_Link *prev
00048 ) : 
00049     m_next(next), 
00050     m_prev(prev) 
00051 {
00052 }
00053 
00054     CTR_Link *
00055 CTR_Link::
00056 getNext(
00057 ) const {
00058     return m_next; 
00059 }
00060 
00061     CTR_Link *
00062 CTR_Link::
00063 getPrev(
00064 ) const { 
00065     return m_prev; 
00066 }  
00067 
00068     bool 
00069 CTR_Link::
00070 isHead(
00071 ) const { 
00072     return m_prev == 0; 
00073 }
00074 
00075     bool 
00076 CTR_Link::
00077 isTail(
00078 ) const { 
00079     return m_next == 0; 
00080 }
00081 
00082     void 
00083 CTR_Link::
00084 insertBefore(
00085     CTR_Link *link
00086 ) {
00087     m_next         = link;
00088     m_prev         = link->m_prev;
00089     m_next->m_prev = this;
00090     m_prev->m_next = this;
00091 } 
00092 
00093     void 
00094 CTR_Link::
00095 insertAfter(
00096     CTR_Link *link
00097 ) {
00098     m_next         = link->m_next;
00099     m_prev         = link;
00100     m_next->m_prev = this;
00101     m_prev->m_next = this;
00102 } 
00103 
00104     void 
00105 CTR_Link::
00106 remove(
00107 ) { 
00108     m_next->m_prev = m_prev; 
00109     m_prev->m_next = m_next;
00110 }
00111 
00112 
00113 CTR_List::
00114 CTR_List(
00115 ) : 
00116     m_head(&m_tail, 0), 
00117     m_tail(0, &m_head) 
00118 {
00119 }
00120 
00121     CTR_Link *
00122 CTR_List::
00123 getHead(
00124 ) const { 
00125     return m_head.getNext(); 
00126 }
00127 
00128     CTR_Link *
00129 CTR_List::
00130 getTail(
00131 ) const { 
00132     return m_tail.getPrev();
00133 } 
00134 
00135     void 
00136 CTR_List::
00137 addHead(
00138     CTR_Link *link
00139 ) { 
00140     link->insertAfter(&m_head); 
00141 }
00142 
00143     void 
00144 CTR_List::
00145 addTail(
00146     CTR_Link *link
00147 ) { 
00148     link->insertBefore(&m_tail); 
00149 }
00150