Bullet Collision Detection & Physics Library: btList.h Source File

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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