32 #ifndef _INCLUDE_SM_QUEUE_H
33 #define _INCLUDE_SM_QUEUE_H
86 Queue() : m_Head(_Initialize()), m_Size(0)
90 Queue(
const Queue &src) : m_Head(_Initialize()), m_Size(0)
93 for (iter=src.begin(); iter!=src.end(); iter++)
110 while (!m_FreeNodes.empty())
112 free(m_FreeNodes.front());
117 void push(
const T &obj)
121 if (m_FreeNodes.empty())
123 node = (QueueNode *)malloc(
sizeof(QueueNode));
125 node = m_FreeNodes.front();
130 new (&node->obj) T(obj);
133 node->prev = m_Head->prev;
135 m_Head->prev->next = node;
148 QueueNode *node = m_Head->next;
150 m_Head->next = m_Head;
151 m_Head->prev = m_Head;
154 while (node != m_Head)
158 m_FreeNodes.push(node);
166 return (m_Size == 0);
172 CStack<QueueNode *> m_FreeNodes;
191 m_This = where.m_This;
197 m_This = m_This->prev;
205 m_This = m_This->prev;
213 m_This = m_This->next;
221 m_This = m_This->next;
225 const T & operator * ()
const
236 return &(m_This->obj);
238 const T * operator -> ()
const
240 return &(m_This->obj);
243 bool operator != (
const iterator &where)
const
245 return (m_This != where.m_This);
247 bool operator ==(
const iterator &where)
const
249 return (m_This == where.m_This);
262 return iterator(m_Head);
265 iterator erase(iterator &where)
267 QueueNode *pNode = where.m_This;
268 iterator iter(where);
273 pNode->prev->next = pNode->next;
274 pNode->next->prev = pNode->prev;
277 m_FreeNodes.push(pNode);
283 void remove(
const T & obj)
286 for (b=begin(); b!=end(); b++)
295 template <
typename U>
296 iterator find(
const U & equ)
const
299 for (iter=begin(); iter!=end(); iter++)
301 if ( (*iter) == equ )
312 for (iter=src.begin(); iter!=src.end(); iter++)
314 push_back( (*iter) );
321 iterator i = begin();
328 iterator iter = begin();
333 #endif //_INCLUDE_SM_QUEUE_H
Definition: sm_queue.h:64
Definition: sm_queue.h:174
Definition: sm_queue.h:69