⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fastlinklist.h

📁 Blood 2全套源码
💻 H
字号:
#ifndef __FASTLINKLIST_H__
#define __FASTLINKLIST_H__


	template<class T>
	class CFastLLNode
	{
		public:
			
			T	*m_pFastLLNext, *m_pFastLLPrev;

	};


	template<class T>
	class CFastLinkedList
	{
		public:

						CFastLinkedList()
						{
							m_Head.m_pFastLLNext = m_Head.m_pFastLLPrev = &m_Tail;
							m_Tail.m_pFastLLNext = m_Tail.m_pFastLLPrev = &m_Head;
						}	
			
			// pCur = list.GetStart();
			// while(list.NotAtEnd(pCur))
			//     list.Increment(pCur);

			T			*GetStart() const
			{
				return (T*)m_Head.m_pFastLLNext;
			}

			BOOL		NotAtEnd(T *thePointer) const
			{
				return thePointer != &m_Tail;
			}

			void		Increment(T* &thePointer) const
			{
				thePointer = (T*)thePointer->m_pFastLLNext;
			}

			void		AddAfter(T *thePointer, T *pAfter)
			{
				thePointer->m_pFastLLPrev = pAfter;
				thePointer->m_pFastLLNext = pAfter->m_pFastLLNext;
				thePointer->m_pFastLLPrev->m_pFastLLNext = 
					thePointer->m_pFastLLNext->m_pFastLLPrev = thePointer;
			}

			void		AddHead(T *thePointer)
			{
				thePointer->m_pFastLLPrev = &m_Head;
				thePointer->m_pFastLLNext = m_Head.m_pFastLLNext;
				thePointer->m_pFastLLPrev->m_pFastLLNext = 
					thePointer->m_pFastLLNext->m_pFastLLPrev = thePointer;
			}

			void		RemoveAt(T *thePointer)
			{
				thePointer->m_pFastLLPrev->m_pFastLLNext = thePointer->m_pFastLLNext;
				thePointer->m_pFastLLNext->m_pFastLLPrev = thePointer->m_pFastLLPrev;
			}

			T	m_Head, m_Tail;

	};


#endif  // __FASTLINKLIST_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -