• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 Copyright (c) 2003-2006 Gino van den Bergen / Erwin Coumans  http://continuousphysics.com/Bullet/
3 
4 This software is provided 'as-is', without any express or implied warranty.
5 In no event will the authors be held liable for any damages arising from the use of this software.
6 Permission is granted to anyone to use this software for any purpose,
7 including commercial applications, and to alter it and redistribute it freely,
8 subject to the following restrictions:
9 
10 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.
11 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12 3. This notice may not be removed or altered from any source distribution.
13 */
14 
15 
16 
17 #ifndef BT_GEN_LIST_H
18 #define BT_GEN_LIST_H
19 
20 class btGEN_Link {
21 public:
btGEN_Link()22     btGEN_Link() : m_next(0), m_prev(0) {}
btGEN_Link(btGEN_Link * next,btGEN_Link * prev)23     btGEN_Link(btGEN_Link *next, btGEN_Link *prev) : m_next(next), m_prev(prev) {}
24 
getNext()25     btGEN_Link *getNext() const { return m_next; }
getPrev()26     btGEN_Link *getPrev() const { return m_prev; }
27 
isHead()28     bool isHead() const { return m_prev == 0; }
isTail()29     bool isTail() const { return m_next == 0; }
30 
insertBefore(btGEN_Link * link)31     void insertBefore(btGEN_Link *link) {
32         m_next         = link;
33         m_prev         = link->m_prev;
34         m_next->m_prev = this;
35         m_prev->m_next = this;
36     }
37 
insertAfter(btGEN_Link * link)38     void insertAfter(btGEN_Link *link) {
39         m_next         = link->m_next;
40         m_prev         = link;
41         m_next->m_prev = this;
42         m_prev->m_next = this;
43     }
44 
remove()45     void remove() {
46         m_next->m_prev = m_prev;
47         m_prev->m_next = m_next;
48     }
49 
50 private:
51     btGEN_Link  *m_next;
52     btGEN_Link  *m_prev;
53 };
54 
55 class btGEN_List {
56 public:
btGEN_List()57     btGEN_List() : m_head(&m_tail, 0), m_tail(0, &m_head) {}
58 
getHead()59     btGEN_Link *getHead() const { return m_head.getNext(); }
getTail()60     btGEN_Link *getTail() const { return m_tail.getPrev(); }
61 
addHead(btGEN_Link * link)62     void addHead(btGEN_Link *link) { link->insertAfter(&m_head); }
addTail(btGEN_Link * link)63     void addTail(btGEN_Link *link) { link->insertBefore(&m_tail); }
64 
65 private:
66     btGEN_Link m_head;
67     btGEN_Link m_tail;
68 };
69 
70 #endif //BT_GEN_LIST_H
71 
72 
73 
74