Blender V2.61 - r43446

btList.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
00003 
00004 This software is provided 'as-is', without any express or implied warranty.
00005 In no event will the authors be held liable for any damages arising from the use of this software.
00006 Permission is granted to anyone to use this software for any purpose, 
00007 including commercial applications, and to alter it and redistribute it freely, 
00008 subject to the following restrictions:
00009 
00010 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
00011 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00012 3. This notice may not be removed or altered from any source distribution.
00013 */
00014 
00015 
00016 
00017 #ifndef GEN_LIST_H
00018 #define GEN_LIST_H
00019 
00020 class btGEN_Link {
00021 public:
00022     btGEN_Link() : m_next(0), m_prev(0) {}
00023     btGEN_Link(btGEN_Link *next, btGEN_Link *prev) : m_next(next), m_prev(prev) {}
00024     
00025     btGEN_Link *getNext() const { return m_next; }  
00026     btGEN_Link *getPrev() const { return m_prev; }  
00027 
00028     bool isHead() const { return m_prev == 0; }
00029     bool isTail() const { return m_next == 0; }
00030 
00031     void insertBefore(btGEN_Link *link) {
00032         m_next         = link;
00033         m_prev         = link->m_prev;
00034         m_next->m_prev = this;
00035         m_prev->m_next = this;
00036     } 
00037 
00038     void insertAfter(btGEN_Link *link) {
00039         m_next         = link->m_next;
00040         m_prev         = link;
00041         m_next->m_prev = this;
00042         m_prev->m_next = this;
00043     } 
00044 
00045     void remove() { 
00046         m_next->m_prev = m_prev; 
00047         m_prev->m_next = m_next;
00048     }
00049 
00050 private:  
00051     btGEN_Link  *m_next;
00052     btGEN_Link  *m_prev;
00053 };
00054 
00055 class btGEN_List {
00056 public:
00057     btGEN_List() : m_head(&m_tail, 0), m_tail(0, &m_head) {}
00058 
00059     btGEN_Link *getHead() const { return m_head.getNext(); } 
00060     btGEN_Link *getTail() const { return m_tail.getPrev(); } 
00061 
00062     void addHead(btGEN_Link *link) { link->insertAfter(&m_head); }
00063     void addTail(btGEN_Link *link) { link->insertBefore(&m_tail); }
00064     
00065 private:
00066     btGEN_Link m_head;
00067     btGEN_Link m_tail;
00068 };
00069 
00070 #endif
00071 
00072 
00073