Blender V2.61 - r43446
|
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 #ifndef GEN_LIST_H 00034 #define GEN_LIST_H 00035 00036 class GEN_Link { 00037 public: 00038 GEN_Link() : m_next(0), m_prev(0) {} 00039 GEN_Link(GEN_Link *next, GEN_Link *prev) : m_next(next), m_prev(prev) {} 00040 00041 GEN_Link *getNext() const { return m_next; } 00042 GEN_Link *getPrev() const { return m_prev; } 00043 00044 bool isHead() const { return m_prev == 0; } 00045 bool isTail() const { return m_next == 0; } 00046 00047 void insertBefore(GEN_Link *link) { 00048 m_next = link; 00049 m_prev = link->m_prev; 00050 m_next->m_prev = this; 00051 m_prev->m_next = this; 00052 } 00053 00054 void insertAfter(GEN_Link *link) { 00055 m_next = link->m_next; 00056 m_prev = link; 00057 m_next->m_prev = this; 00058 m_prev->m_next = this; 00059 } 00060 00061 void remove() { 00062 m_next->m_prev = m_prev; 00063 m_prev->m_next = m_next; 00064 } 00065 00066 private: 00067 GEN_Link *m_next; 00068 GEN_Link *m_prev; 00069 }; 00070 00071 class GEN_List { 00072 public: 00073 GEN_List() : m_head(&m_tail, 0), m_tail(0, &m_head) {} 00074 00075 GEN_Link *getHead() const { return m_head.getNext(); } 00076 GEN_Link *getTail() const { return m_tail.getPrev(); } 00077 00078 void addHead(GEN_Link *link) { link->insertAfter(&m_head); } 00079 void addTail(GEN_Link *link) { link->insertBefore(&m_tail); } 00080 00081 private: 00082 GEN_Link m_head; 00083 GEN_Link m_tail; 00084 }; 00085 00086 #endif 00087