ReactOS  0.4.12-dev-18-gf469aca
ATL::CAtlList< E, ETraits > Class Template Reference

#include <atlcoll.h>

Collaboration diagram for ATL::CAtlList< E, ETraits >:

Classes

class  CNode
 

Public Member Functions

 CAtlList (_In_ UINT nBlockSize=10)
 
 ~CAtlList ()
 
size_t GetCount () const
 
bool IsEmpty () const
 
POSITION GetHeadPosition () const
 
POSITION GetTailPosition () const
 
EGetNext (_Inout_ POSITION &pos)
 
const EGetNext (_Inout_ POSITION &pos) const
 
EGetPrev (_Inout_ POSITION &pos)
 
const EGetPrev (_Inout_ POSITION &pos) const
 
EGetAt (_In_ POSITION pos)
 
const EGetAt (_In_ POSITION pos) const
 
POSITION AddHead (INARGTYPE element)
 
POSITION AddTail (INARGTYPE element)
 
E RemoveHead ()
 
E RemoveTail ()
 
void RemoveAll ()
 
void RemoveAt (_In_ POSITION pos)
 
POSITION Find (INARGTYPE element, _In_opt_ POSITION posStartAfter=NULL) const
 
POSITION FindIndex (_In_ size_t iElement) const
 

Private Types

typedef ETraits::INARGTYPE INARGTYPE
 

Private Member Functions

 CAtlList (_In_ const CAtlList &)
 
CAtlListoperator= (_In_ const CAtlList &)
 
CNodeCreateNode (INARGTYPE element, _In_opt_ CNode *pPrev, _In_opt_ CNode *pNext)
 
void FreeNode (_Inout_ CNode *pNode)
 
CNodeGetFreeNode ()
 

Private Attributes

CAtlPlexm_Blocks
 
UINT m_BlockSize
 
CNodem_HeadNode
 
CNodem_TailNode
 
CNodem_FreeNode
 
size_t m_NumElements
 

Detailed Description

template<typename E, class ETraits = CElementTraits<E>>
class ATL::CAtlList< E, ETraits >

Definition at line 140 of file atlcoll.h.

Member Typedef Documentation

◆ INARGTYPE

template<typename E, class ETraits = CElementTraits<E>>
typedef ETraits::INARGTYPE ATL::CAtlList< E, ETraits >::INARGTYPE
private

Definition at line 143 of file atlcoll.h.

Constructor & Destructor Documentation

◆ CAtlList() [1/2]

template<typename E, class ETraits = CElementTraits<E>>
ATL::CAtlList< E, ETraits >::CAtlList ( _In_ const CAtlList< E, ETraits > &  )
private

◆ CAtlList() [2/2]

template<typename E , class ETraits >
ATL::CAtlList< E, ETraits >::CAtlList ( _In_ UINT  nBlockSize = 10)

Definition at line 231 of file atlcoll.h.

231  :
232  m_Blocks(NULL),
233  m_BlockSize(nBlockSize),
234  m_HeadNode(NULL),
235  m_TailNode(NULL),
236  m_FreeNode(NULL),
237  m_NumElements(0)
238 {
239  ATLASSERT(nBlockSize > 0);
240 }
UINT m_BlockSize
Definition: atlcoll.h:167
#define ATLASSERT(x)
Definition: CComVariant.cpp:9
CAtlPlex * m_Blocks
Definition: atlcoll.h:166
smooth NULL
Definition: ftsmooth.c:416
size_t m_NumElements
Definition: atlcoll.h:171
CNode * m_FreeNode
Definition: atlcoll.h:170
CNode * m_HeadNode
Definition: atlcoll.h:168
CNode * m_TailNode
Definition: atlcoll.h:169

◆ ~CAtlList()

template<typename E , class ETraits >
ATL::CAtlList< E, ETraits >::~CAtlList ( void  )

Definition at line 243 of file atlcoll.h.

244 {
245  RemoveAll();
246 }
void RemoveAll()
Definition: atlcoll.h:393

Member Function Documentation

◆ AddHead()

template<typename E , class ETraits >
POSITION ATL::CAtlList< E, ETraits >::AddHead ( INARGTYPE  element)

Definition at line 319 of file atlcoll.h.

320 {
322  if (m_HeadNode)
323  {
325  }
326  else
327  {
328  m_TailNode = Node;
329  }
330  m_HeadNode = Node;
331 
332  return (POSITION)Node;
333 }
CNode * CreateNode(INARGTYPE element, _In_opt_ CNode *pPrev, _In_opt_ CNode *pNext)
Definition: atlcoll.h:486
smooth NULL
Definition: ftsmooth.c:416
Definition: Node.h:12
CNode * m_HeadNode
Definition: atlcoll.h:168
union gl_dlist_node Node
Definition: dlist.c:302
CNode * m_TailNode
Definition: atlcoll.h:169

◆ AddTail()

template<typename E , class ETraits >
POSITION ATL::CAtlList< E, ETraits >::AddTail ( INARGTYPE  element)

Definition at line 336 of file atlcoll.h.

Referenced by CIconWatcher::AddIconToWatcher(), and ValidateItem().

337 {
339  if (m_TailNode)
340  {
342  }
343  else
344  {
345  m_HeadNode = Node;
346  }
347  m_TailNode = Node;
348 
349  return (POSITION)Node;
350 }
CNode * CreateNode(INARGTYPE element, _In_opt_ CNode *pPrev, _In_opt_ CNode *pNext)
Definition: atlcoll.h:486
smooth NULL
Definition: ftsmooth.c:416
Definition: Node.h:12
CNode * m_HeadNode
Definition: atlcoll.h:168
union gl_dlist_node Node
Definition: dlist.c:302
CNode * m_TailNode
Definition: atlcoll.h:169

◆ CreateNode()

template<typename E , class ETraits >
CAtlList< E, ETraits >::CNode * ATL::CAtlList< E, ETraits >::CreateNode ( INARGTYPE  element,
_In_opt_ CNode pPrev,
_In_opt_ CNode pNext 
)
private

Definition at line 486 of file atlcoll.h.

491 {
492  GetFreeNode();
493 
494  CNode* NewNode = m_FreeNode;
495  CNode* NextFree = m_FreeNode->m_Next;
496 
497  NewNode = new CNode(element);
498 
499  m_FreeNode = NextFree;
500  NewNode->m_Prev = Prev;
501  NewNode->m_Next = Next;
502  m_NumElements++;
503 
504  return NewNode;
505 }
CNode * GetFreeNode()
Definition: atlcoll.h:524
Definition: Node.h:12
size_t m_NumElements
Definition: atlcoll.h:171
CNode * m_FreeNode
Definition: atlcoll.h:170

◆ Find()

template<typename E , class ETraits >
POSITION ATL::CAtlList< E, ETraits >::Find ( INARGTYPE  element,
_In_opt_ POSITION  posStartAfter = NULL 
) const

Definition at line 439 of file atlcoll.h.

Referenced by AddService(), and ValidateItem().

442 {
443  CNode* Node = (CNode*)posStartAfter;
444  if (Node == NULL)
445  {
446  Node = m_HeadNode;
447  }
448  else
449  {
450  Node = Node->m_Next;
451  }
452 
453  for (; Node != NULL; Node = Node->m_Next)
454  {
455  if (ETraits::CompareElements(Node->m_Element, element))
456  return (POSITION)Node;
457  }
458 
459  return NULL;
460 }
smooth NULL
Definition: ftsmooth.c:416
Definition: Node.h:12
CNode * m_HeadNode
Definition: atlcoll.h:168
union gl_dlist_node Node
Definition: dlist.c:302

◆ FindIndex()

template<typename E , class ETraits >
POSITION ATL::CAtlList< E, ETraits >::FindIndex ( _In_ size_t  iElement) const

Definition at line 463 of file atlcoll.h.

Referenced by CIconWatcher::Uninitialize(), and CIconWatcher::WatcherThread().

464 {
465  if (iElement >= m_NumElements)
466  return NULL;
467 
468  if (m_HeadNode == NULL)
469  return NULL;
470 
471  CNode* Node = m_HeadNode;
472  for (size_t i = 0; i < iElement; i++)
473  {
474  Node = Node->m_Next;
475  }
476 
477  return (POSITION)Node;
478 }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
Definition: Node.h:12
size_t m_NumElements
Definition: atlcoll.h:171
CNode * m_HeadNode
Definition: atlcoll.h:168
union gl_dlist_node Node
Definition: dlist.c:302

◆ FreeNode()

template<typename E , class ETraits >
void ATL::CAtlList< E, ETraits >::FreeNode ( _Inout_ CNode pNode)
private

Definition at line 508 of file atlcoll.h.

511 {
512  pNode->~CNode();
513  pNode->m_Next = m_FreeNode;
514  m_FreeNode = pNode;
515 
516  m_NumElements--;
517  if (m_NumElements == 0)
518  {
519  RemoveAll();
520  }
521 }
void RemoveAll()
Definition: atlcoll.h:393
size_t m_NumElements
Definition: atlcoll.h:171
CNode * m_FreeNode
Definition: atlcoll.h:170

◆ GetAt() [1/2]

template<typename E , class ETraits >
E & ATL::CAtlList< E, ETraits >::GetAt ( _In_ POSITION  pos)
inline

Definition at line 305 of file atlcoll.h.

Referenced by ServicesPageWndProc(), CIconWatcher::Uninitialize(), and CIconWatcher::WatcherThread().

306 {
307  CNode* Node = (CNode*)pos;
308  return Node->m_Element;
309 }
Definition: Node.h:12

◆ GetAt() [2/2]

template<typename E , class ETraits >
const E & ATL::CAtlList< E, ETraits >::GetAt ( _In_ POSITION  pos) const
inline

Definition at line 312 of file atlcoll.h.

313 {
314  CNode* Node = (CNode*)pos;
315  return Node->m_Element;
316 }
Definition: Node.h:12

◆ GetCount()

template<typename E , class ETraits >
size_t ATL::CAtlList< E, ETraits >::GetCount ( ) const
inline

Definition at line 249 of file atlcoll.h.

Referenced by CIconWatcher::AddIconToWatcher(), CIconWatcher::Uninitialize(), and CIconWatcher::WatcherThread().

250 {
251  return m_NumElements;
252 }
size_t m_NumElements
Definition: atlcoll.h:171

◆ GetFreeNode()

template<typename E , class ETraits >
CAtlList< E, ETraits >::CNode * ATL::CAtlList< E, ETraits >::GetFreeNode ( )
private

Definition at line 524 of file atlcoll.h.

525 {
526  if (m_FreeNode)
527  {
528  return m_FreeNode;
529  }
530 
531  CAtlPlex* Block = CAtlPlex::Create(m_Blocks, m_BlockSize, sizeof(CNode));
532  if (Block == NULL)
533  {
535  }
536 
537  CNode* Node = (CNode*)Block->GetData();
538  Node += (m_BlockSize - 1);
539  for (int i = m_BlockSize - 1; i >= 0; i--)
540  {
541  Node->m_Next = m_FreeNode;
542  m_FreeNode = Node;
543  Node--;
544  }
545 
546  return m_FreeNode;
547 }
UINT m_BlockSize
Definition: atlcoll.h:167
CAtlPlex * m_Blocks
Definition: atlcoll.h:166
void AtlThrowImp(HRESULT hr)
Definition: atlexcept.h:15
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
Definition: Node.h:12
void * GetData()
Definition: atlcoll.h:49
CNode * m_FreeNode
Definition: atlcoll.h:170
static CAtlPlex * Create(_Inout_ CAtlPlex *&Entry, _In_ size_t MaxElements, _In_ size_t ElementSize)
Definition: atlcoll.h:26
union gl_dlist_node Node
Definition: dlist.c:302

◆ GetHeadPosition()

template<typename E , class ETraits >
POSITION ATL::CAtlList< E, ETraits >::GetHeadPosition ( ) const
inline

Definition at line 261 of file atlcoll.h.

Referenced by CIconWatcher::GetListEntry(), and ServicesPageWndProc().

262 {
263  return (POSITION)m_HeadNode;
264 }
CNode * m_HeadNode
Definition: atlcoll.h:168

◆ GetNext() [1/2]

template<typename E , class ETraits >
E & ATL::CAtlList< E, ETraits >::GetNext ( _Inout_ POSITION pos)
inline

Definition at line 273 of file atlcoll.h.

Referenced by CIconWatcher::GetListEntry(), and ServicesPageWndProc().

274 {
275  CNode* Node = (CNode*)pos;
276  pos = (POSITION)Node->m_Next;
277  return Node->m_Element;
278 }
Definition: Node.h:12
__POSITION * POSITION
Definition: atlcoll.h:11

◆ GetNext() [2/2]

template<typename E , class ETraits >
const E & ATL::CAtlList< E, ETraits >::GetNext ( _Inout_ POSITION pos) const
inline

Definition at line 281 of file atlcoll.h.

282 {
283  CNode* Node = (CNode*)pos;
284  pos = (POSITION)Node->m_Next;
285  return Node->m_Element;
286 }
Definition: Node.h:12
__POSITION * POSITION
Definition: atlcoll.h:11

◆ GetPrev() [1/2]

template<typename E , class ETraits >
E & ATL::CAtlList< E, ETraits >::GetPrev ( _Inout_ POSITION pos)
inline

Definition at line 289 of file atlcoll.h.

290 {
291  CNode* Node = (CNode*)pos;
292  pos = (POSITION)Node->m_Prev;
293  return Node->m_Element;
294 }
Definition: Node.h:12
__POSITION * POSITION
Definition: atlcoll.h:11

◆ GetPrev() [2/2]

template<typename E , class ETraits >
const E & ATL::CAtlList< E, ETraits >::GetPrev ( _Inout_ POSITION pos) const
inline

Definition at line 297 of file atlcoll.h.

298 {
299  CNode* Node = (CNode*)pos;
300  pos = (POSITION)Node->m_Prev;
301  return Node->m_Element;
302 }
Definition: Node.h:12
__POSITION * POSITION
Definition: atlcoll.h:11

◆ GetTailPosition()

template<typename E , class ETraits >
POSITION ATL::CAtlList< E, ETraits >::GetTailPosition ( ) const
inline

Definition at line 267 of file atlcoll.h.

268 {
269  return (POSITION)m_TailNode;
270 }
CNode * m_TailNode
Definition: atlcoll.h:169

◆ IsEmpty()

template<typename E , class ETraits >
bool ATL::CAtlList< E, ETraits >::IsEmpty ( ) const
inline

Definition at line 255 of file atlcoll.h.

256 {
257  return (m_NumElements == 0);
258 }
size_t m_NumElements
Definition: atlcoll.h:171

◆ operator=()

template<typename E, class ETraits = CElementTraits<E>>
CAtlList& ATL::CAtlList< E, ETraits >::operator= ( _In_ const CAtlList< E, ETraits > &  )
private

◆ RemoveAll()

template<typename E , class ETraits >
void ATL::CAtlList< E, ETraits >::RemoveAll ( )

Definition at line 393 of file atlcoll.h.

Referenced by ServicesPageWndProc(), and CIconWatcher::Uninitialize().

394 {
395  while (m_NumElements > 0)
396  {
397  CNode* Node = m_HeadNode;
399  FreeNode(Node);
400  }
401 
402  m_HeadNode = NULL;
403  m_TailNode = NULL;
404  m_FreeNode = NULL;
405 
406  if (m_Blocks)
407  {
408  m_Blocks->Destroy();
409  m_Blocks = NULL;
410  }
411 }
CAtlPlex * m_Blocks
Definition: atlcoll.h:166
void FreeNode(_Inout_ CNode *pNode)
Definition: atlcoll.h:508
smooth NULL
Definition: ftsmooth.c:416
void Destroy()
Definition: atlcoll.h:54
Definition: Node.h:12
size_t m_NumElements
Definition: atlcoll.h:171
CNode * m_FreeNode
Definition: atlcoll.h:170
CNode * m_HeadNode
Definition: atlcoll.h:168
CNode * m_TailNode
Definition: atlcoll.h:169

◆ RemoveAt()

template<typename E , class ETraits >
void ATL::CAtlList< E, ETraits >::RemoveAt ( _In_ POSITION  pos)

Definition at line 414 of file atlcoll.h.

Referenced by CIconWatcher::GetListEntry(), and ValidateItem().

415 {
416  ATLASSERT(pos != NULL);
417 
418  CNode* OldNode = (CNode*)pos;
419  if (OldNode == m_HeadNode)
420  {
421  m_HeadNode = OldNode->m_Next;
422  }
423  else
424  {
425  OldNode->m_Prev->m_Next = OldNode->m_Next;
426  }
427  if (OldNode == m_TailNode)
428  {
429  m_TailNode = OldNode->m_Prev;
430  }
431  else
432  {
433  OldNode->m_Next->m_Prev = OldNode->m_Prev;
434  }
435  FreeNode(OldNode);
436 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:9
void FreeNode(_Inout_ CNode *pNode)
Definition: atlcoll.h:508
smooth NULL
Definition: ftsmooth.c:416
Definition: Node.h:12
CNode * m_HeadNode
Definition: atlcoll.h:168
CNode * m_TailNode
Definition: atlcoll.h:169

◆ RemoveHead()

template<typename E , class ETraits >
E ATL::CAtlList< E, ETraits >::RemoveHead ( )

Definition at line 353 of file atlcoll.h.

354 {
355  CNode* Node = m_HeadNode;
356  E Element(Node->m_Element);
357 
358  m_HeadNode = Node->m_Next;
359  if (m_HeadNode)
360  {
362  }
363  else
364  {
365  m_TailNode = NULL;
366  }
367  FreeNode(Node);
368 
369  return Element;
370 }
void FreeNode(_Inout_ CNode *pNode)
Definition: atlcoll.h:508
smooth NULL
Definition: ftsmooth.c:416
Definition: Node.h:12
static const WCHAR E[]
Definition: oid.c:1090
CNode * m_HeadNode
Definition: atlcoll.h:168
CNode * m_TailNode
Definition: atlcoll.h:169

◆ RemoveTail()

template<typename E , class ETraits >
E ATL::CAtlList< E, ETraits >::RemoveTail ( )

Definition at line 373 of file atlcoll.h.

374 {
375  CNode* Node = m_TailNode;
376  E Element(Node->m_Element);
377 
378  m_TailNode = Node->m_Prev;
379  if (m_TailNode)
380  {
382  }
383  else
384  {
385  m_HeadNode = NULL;
386  }
387  FreeNode(Node);
388 
389  return Element;
390 }
void FreeNode(_Inout_ CNode *pNode)
Definition: atlcoll.h:508
smooth NULL
Definition: ftsmooth.c:416
Definition: Node.h:12
static const WCHAR E[]
Definition: oid.c:1090
CNode * m_HeadNode
Definition: atlcoll.h:168
CNode * m_TailNode
Definition: atlcoll.h:169

Member Data Documentation

◆ m_Blocks

template<typename E, class ETraits = CElementTraits<E>>
CAtlPlex* ATL::CAtlList< E, ETraits >::m_Blocks
private

Definition at line 166 of file atlcoll.h.

◆ m_BlockSize

template<typename E, class ETraits = CElementTraits<E>>
UINT ATL::CAtlList< E, ETraits >::m_BlockSize
private

Definition at line 167 of file atlcoll.h.

◆ m_FreeNode

template<typename E, class ETraits = CElementTraits<E>>
CNode* ATL::CAtlList< E, ETraits >::m_FreeNode
private

Definition at line 170 of file atlcoll.h.

◆ m_HeadNode

template<typename E, class ETraits = CElementTraits<E>>
CNode* ATL::CAtlList< E, ETraits >::m_HeadNode
private

Definition at line 168 of file atlcoll.h.

◆ m_NumElements

template<typename E, class ETraits = CElementTraits<E>>
size_t ATL::CAtlList< E, ETraits >::m_NumElements
private

Definition at line 171 of file atlcoll.h.

◆ m_TailNode

template<typename E, class ETraits = CElementTraits<E>>
CNode* ATL::CAtlList< E, ETraits >::m_TailNode
private

Definition at line 169 of file atlcoll.h.


The documentation for this class was generated from the following file: