OROCHI
 
Loading...
Searching...
No Matches
GxList.h
Go to the documentation of this file.
1//===========================================================================
9//===========================================================================
10#pragma once
11
12GX_CORE_NAMESPACE_BEGIN()
13
14//===========================================================================
16//===========================================================================
17class GxList : public GxClassBase
18{
19 //-------------------------------------------------------------
21 //-------------------------------------------------------------
23public:
24 // RTTI宣言
25 GX_RTTI_CLASS(GxList, GxClassBase)
26 // GxClassBase継承クラス用禁止宣言
28
29
30 class GxNode;
32 template <class T> class GxIterator;
33
35 //-------------------------------------------------------------
37 //-------------------------------------------------------------
39
41 GxList(void) : _pTop(nullptr), _pBottom(nullptr), _count(0), _allocatorType(GxAllocatorList::ALLOCATOR_TYPE::GLOBAL){}
45 ~GxList(void) override;
46protected:
48 virtual GxNode* allocGxNode(void);
49
51 //-------------------------------------------------------------
53 //-------------------------------------------------------------
55public:
57 GX_FORCE_INLINE GxIterator<void*> begin(void);
59 GX_FORCE_INLINE GxIterator<void*> end(void);
61 constexpr GxNode* getTop(void) const { return _pTop; }
63 constexpr GxNode* getBottom(void) const { return _pBottom; }
65 GxNode* getNode(u32 index) const;
67 constexpr u32 getCount(void) const { return _count; }
69 constexpr void setAllocatorType(GxAllocatorList::ALLOCATOR_TYPE allocatorType){ _allocatorType = allocatorType; }
70
72 //-------------------------------------------------------------
74 //-------------------------------------------------------------
76
78 GxNode* addTop(void* pObject);
80 GxNode* addBottom(void* pObject);
82 void insert(GxNode* pNode, void* pObject);
84 virtual void erase(GxNode* pNode);
86 virtual void eraseAll(void);
87
89 //-------------------------------------------------------------
91 //-------------------------------------------------------------
93protected:
96 u32 _count;
98
100};
101
102//===========================================================================
104//===========================================================================
106{
107 //-------------------------------------------------------------
109 //-------------------------------------------------------------
111public:
112 GX_RTTI_CLASS(GxList::GxNode, GxClassBase)
113 // GxClassBase継承クラス用禁止宣言
115
116 friend class GxList;
117 friend class GxListReference;
118
120 //-------------------------------------------------------------
122 //-------------------------------------------------------------
124
126 GxNode(void) : _pObject(nullptr), _pParent(nullptr), _pPrevious(nullptr), _pNext(nullptr){}
128 ~GxNode(void) override {}
129
131 //-------------------------------------------------------------
133 //-------------------------------------------------------------
135
137 constexpr GxList* getParent(void) const { return _pParent; }
139 constexpr GxNode* getPrevious(void) const { return _pPrevious; }
141 constexpr GxNode* getNext(void) const { return _pNext; }
143 constexpr void* getObject(void) const { return _pObject; }
144protected:
146 virtual void setObject(void* pObject){ _pObject = pObject; }
147
149 //-------------------------------------------------------------
151 //-------------------------------------------------------------
153
154protected:
155 void* _pObject;
157private:
158 GxNode* _pPrevious;
159 GxNode* _pNext;
160
162};
163
164//===========================================================================
166//===========================================================================
167template<class T> class GxList::GxIterator
168{
169 //-----------------------------------------------------------
171 //-----------------------------------------------------------
173public :
175 GX_FORCE_INLINE GxIterator(GxList* pGxList) : _pList(pGxList){ _pCurrent = _pList->getTop(); }
177 GX_FORCE_INLINE GxIterator(const GxList::GxIterator<T> &i) : _pList(i._pList), _pCurrent(i._pCurrent){}
179 virtual ~GxIterator(void){}
180
182 //-----------------------------------------------------------
184 //-----------------------------------------------------------
186
188 GX_FORCE_INLINE const GxList::GxIterator<T>& operator = (GxList::GxIterator<T> &i){ _pList = i._pList; _pCurrent = i._pCurrent; return this; }
190 T operator*(void) const { return getCurrent(); }
192 GX_FORCE_INLINE GxIterator<T>& operator++(void) { getNext(); return *this; }
194 GX_FORCE_INLINE b32 operator!=(const GxIterator& iterator) const { return getCurrent() != iterator.getCurrent(); }
195
197 //-----------------------------------------------------------
199 //-----------------------------------------------------------
201
203 GX_FORCE_INLINE const T operator[](u32 i) const;
205 GX_FORCE_INLINE T operator[](u32 i);
207 GX_FORCE_INLINE T getTop(void);
209 GX_FORCE_INLINE T getBottom(void);
211 GX_FORCE_INLINE T getPrevious(void);
213 GX_FORCE_INLINE T getCurrent(void) const;
215 GX_FORCE_INLINE T getNext(void);
217 GX_FORCE_INLINE T getFromIndex(u32 index) const { return this[index]; }
219 constexpr GxNode* getCurrentNode(void) const { return _pCurrent; }
220
222 //-----------------------------------------------------------
224 //-----------------------------------------------------------
226
227private:
228 GxList* _pList;
229 GxNode* _pCurrent;
230
232};
233
234#include "GxList.inl"
235
236GX_CORE_NAMESPACE_END()
#define GX_PROHIBIT_CLASS_BASE(__CLASS__)
GxClassBase継承の禁止宣言
Definition GxBase.h:240
連結リスト
メモリアロケータリスト
Definition GxAllocator.h:347
ALLOCATOR_TYPE
アロケータ定義
Definition GxAllocator.h:355
オブジェクト基底クラス
Definition GxBase.h:88
イテレータ
Definition GxList.h:168
GX_FORCE_INLINE b32 operator!=(const GxIterator &iterator) const
不一致判定
Definition GxList.h:194
GX_FORCE_INLINE T getNext(void)
次を取得
Definition GxList.inl:131
GX_FORCE_INLINE const T operator[](u32 i) const
const配列
Definition GxList.inl:38
GX_FORCE_INLINE GxIterator< T > & operator++(void)
インクリメント
Definition GxList.h:192
GX_FORCE_INLINE GxIterator(GxList *pGxList)
コンストラクタ
Definition GxList.h:175
virtual ~GxIterator(void)
デストラクタ
Definition GxList.h:179
GX_FORCE_INLINE T getPrevious(void)
前を取得
Definition GxList.inl:99
GX_FORCE_INLINE T getBottom(void)
終端を取得
Definition GxList.inl:84
GX_FORCE_INLINE T getFromIndex(u32 index) const
指定インデックスのものを取得
Definition GxList.h:217
GX_FORCE_INLINE const GxList::GxIterator< T > & operator=(GxList::GxIterator< T > &i)
代入
Definition GxList.h:188
constexpr GxNode * getCurrentNode(void) const
カレントノードを取得
Definition GxList.h:219
T operator*(void) const
オブジェクト取得
Definition GxList.h:190
GX_FORCE_INLINE T getTop(void)
先頭を取得
Definition GxList.inl:69
GX_FORCE_INLINE T getCurrent(void) const
現在のオブジェクトを取得
Definition GxList.inl:117
GX_FORCE_INLINE GxIterator(const GxList::GxIterator< T > &i)
コピーコンストラクタ
Definition GxList.h:177
連結リストノードクラス
Definition GxList.h:106
constexpr GxNode * getPrevious(void) const
前のノードを取得
Definition GxList.h:139
GxList * _pParent
親リスト
Definition GxList.h:156
constexpr GxNode * getNext(void) const
次のノードを取得
Definition GxList.h:141
void * _pObject
所有オブジェクト
Definition GxList.h:155
~GxNode(void) override
デストラクタ
Definition GxList.h:128
GxNode(void)
デフォルトコンストラクタ
Definition GxList.h:126
virtual void setObject(void *pObject)
オブジェクトを設定
Definition GxList.h:146
constexpr void * getObject(void) const
オブジェクトを取得
Definition GxList.h:143
constexpr GxList * getParent(void) const
自分が所属するリストを取得
Definition GxList.h:137
連結リストクラス
Definition GxList.h:18
constexpr GxNode * getTop(void) const
先頭を取得
Definition GxList.h:61
u32 _count
ノード数
Definition GxList.h:96
GxAllocatorList::ALLOCATOR_TYPE _allocatorType
アロケータ種別
Definition GxList.h:97
GxList(void)
デフォルトコンストラクタ
Definition GxList.h:41
GxList::GxNode * _pBottom
終端ノード
Definition GxList.h:95
constexpr GxNode * getBottom(void) const
終端を取得
Definition GxList.h:63
constexpr u32 getCount(void) const
要素数を取得
Definition GxList.h:67
constexpr void setAllocatorType(GxAllocatorList::ALLOCATOR_TYPE allocatorType)
アロケータタイプを指定
Definition GxList.h:69
GxList::GxNode * _pTop
先頭ノード
Definition GxList.h:94
32bitブーリアン
Definition GxDefine.h:173