17 #include <pia/common/common_definitions.h> 18 #include <pia/common/common_ListBase.h> 51 class OffsetList :
public nn::pia::common::ListBase
61 : ListBase(), m_Offset(-1)
73 void InitOffset(s32 offset)
93 void PushBack(T* pObj)
95 PushBackNode(ObjToListNode(pObj));
104 void PushFront(T* pObj)
106 PushFrontNode(ObjToListNode(pObj));
118 return ListNodeToObjWithNullCheck(PopBackNode());
130 return ListNodeToObjWithNullCheck(PopFrontNode());
141 void InsertBefore(
const T* pBasis, T* pObj)
143 InsertBeforeNode(ObjToListNode(pBasis), ObjToListNode(pObj));
154 void InsertAfter(
const T* pBasis, T* pObj)
156 InsertAfterNode(ObjToListNode(pBasis), ObjToListNode(pObj));
169 EraseNode(ObjToListNode(pObj));
181 return ListNodeToObjWithNullCheck(FrontNode());
193 return ListNodeToObjWithNullCheck(BackNode());
206 T* Prev(
const T* pObj)
const 208 ListNode* pPrev = ObjToListNode(pObj)->Prev();
209 if (pPrev == Terminator())
215 return ListNodeToObj(pPrev);
229 T* Next(
const T* pObj)
const 231 ListNode* pNext = ObjToListNode(pObj)->Next();
232 if (pNext == Terminator())
238 return ListNodeToObj(pNext);
250 bool IsInclude(
const T* pObj)
const 252 return IsIncludeNode(ObjToListNode(pObj));
262 void Rotate(
const T* pObj)
264 RotateNode(ObjToListNode(pObj));
273 friend class OffsetList<T>;
276 Iterator(
const OffsetList<T>* pList, T* pObj)
277 : m_pList(pList), m_pObj(pObj)
282 Iterator& operator++()
284 m_pObj = m_pList->ListNodeToObj(m_pList->ObjToListNode(m_pObj)->Next());
288 bool operator==(
const Iterator& x)
const 290 return m_pObj == x.m_pObj;
292 bool operator!=(
const Iterator& x)
const 294 return m_pObj != x.m_pObj;
306 const OffsetList<T>* GetList()
const 312 const OffsetList<T>* m_pList;
322 friend class OffsetList<T>;
325 ConstIterator(
const OffsetList<T>* pList,
const T* pObj)
326 : m_pList(pList), m_pObj(pObj)
331 ConstIterator& operator++()
333 m_pObj = m_pList->ListNodeToObj(m_pList->ObjToListNode(m_pObj)->Next());
337 bool operator==(
const ConstIterator& x)
const 339 return m_pObj == x.m_pObj;
341 bool operator!=(
const ConstIterator& x)
const 343 return m_pObj != x.m_pObj;
350 const T* operator->()
355 const OffsetList<T>* GetList()
const 361 const OffsetList<T>* m_pList;
374 friend class OffsetList<T>;
377 RobustIterator(
const OffsetList<T>* pList, T* pObj)
378 : m_pList(pList), m_pObj(pObj)
380 m_pNextNode = m_pList->ObjToListNode(pObj)->Next();
384 RobustIterator& operator++()
386 m_pObj = m_pList->ListNodeToObj(m_pNextNode);
387 m_pNextNode = m_pList->ObjToListNode(m_pObj)->Next();
391 bool operator==(
const RobustIterator& x)
const 393 return m_pObj == x.m_pObj;
395 bool operator!=(
const RobustIterator& x)
const 397 return m_pObj != x.m_pObj;
409 const OffsetList<T>* GetList()
const 415 const OffsetList<T>* m_pList;
417 ListNode* m_pNextNode;
426 Iterator Begin()
const 428 return Iterator(
this, ListNodeToObj(Terminator()->Next()));
439 return Iterator(
this, ListNodeToObj(Terminator()));
448 ConstIterator ConstBegin()
const 450 return ConstIterator(
this, ListNodeToObj(Terminator()->Next()));
459 ConstIterator ConstEnd()
const 461 return ConstIterator(
this, ListNodeToObj(Terminator()));
470 RobustIterator RobustBegin()
const 472 return RobustIterator(
this, ListNodeToObj(Terminator()->Next()));
481 RobustIterator RobustEnd()
const 483 return RobustIterator(
this, ListNodeToObj(Terminator()));
490 ListNode* ObjToListNode(
const T* pObj)
const 492 return reinterpret_cast<ListNode*
>((
reinterpret_cast<u32
>(pObj)) + m_Offset);
495 T* ListNodeToObj(
const ListNode* pNode)
const 497 return reinterpret_cast<T*
>((
reinterpret_cast<u32
>(pNode)) - m_Offset);
500 T* ListNodeToObjWithNullCheck(
const ListNode* pNode)
const 503 return reinterpret_cast<T*
>((
reinterpret_cast<u32
>(pNode)) - m_Offset);