Bullet Collision Detection & Physics Library
btList.h
Go to the documentation of this file.
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:
22  btGEN_Link() : m_next(0), m_prev(0) {}
23  btGEN_Link(btGEN_Link *next, btGEN_Link *prev) : m_next(next), m_prev(prev) {}
24 
25  btGEN_Link *getNext() const { return m_next; }
26  btGEN_Link *getPrev() const { return m_prev; }
27 
28  bool isHead() const { return m_prev == 0; }
29  bool isTail() const { return m_next == 0; }
30 
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 
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 
45  void remove() {
46  m_next->m_prev = m_prev;
47  m_prev->m_next = m_next;
48  }
49 
50 private:
53 };
54 
55 class btGEN_List {
56 public:
57  btGEN_List() : m_head(&m_tail, 0), m_tail(0, &m_head) {}
58 
59  btGEN_Link *getHead() const { return m_head.getNext(); }
60  btGEN_Link *getTail() const { return m_tail.getPrev(); }
61 
62  void addHead(btGEN_Link *link) { link->insertAfter(&m_head); }
63  void addTail(btGEN_Link *link) { link->insertBefore(&m_tail); }
64 
65 private:
68 };
69 
70 #endif //BT_GEN_LIST_H
71 
72 
73 
btGEN_Link * getHead() const
Definition: btList.h:59
void addHead(btGEN_Link *link)
Definition: btList.h:62
btGEN_List()
Definition: btList.h:57
btGEN_Link * getTail() const
Definition: btList.h:60
btGEN_Link m_tail
Definition: btList.h:67
btGEN_Link m_head
Definition: btList.h:66
void addTail(btGEN_Link *link)
Definition: btList.h:63