ReactOS 0.4.15-dev-5836-g942b022
ATL::CAtlList< E, ETraits > Class Template Reference

#include <atlcoll.h>

Inheritance diagram for ATL::CAtlList< E, ETraits >:
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 ()
 
POSITION InsertBefore (_In_ POSITION pos, INARGTYPE element)
 
POSITION InsertAfter (_In_ POSITION pos, INARGTYPE element)
 
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 424 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 427 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 519 of file atlcoll.h.

519 :
520 m_Blocks(NULL),
521 m_BlockSize(nBlockSize),
526{
527 ATLASSERT(nBlockSize > 0);
528}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
CNode * m_HeadNode
Definition: atlcoll.h:452
CNode * m_TailNode
Definition: atlcoll.h:453
CNode * m_FreeNode
Definition: atlcoll.h:454
UINT m_BlockSize
Definition: atlcoll.h:451
size_t m_NumElements
Definition: atlcoll.h:455
CAtlPlex * m_Blocks
Definition: atlcoll.h:450
#define NULL
Definition: types.h:112

◆ ~CAtlList()

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

Definition at line 531 of file atlcoll.h.

532{
533 RemoveAll();
534}
void RemoveAll()
Definition: atlcoll.h:725

Member Function Documentation

◆ AddHead()

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

Definition at line 607 of file atlcoll.h.

608{
610 if (m_HeadNode)
611 {
613 }
614 else
615 {
617 }
619
620 return (POSITION)Node;
621}
CNode * CreateNode(INARGTYPE element, _In_opt_ CNode *pPrev, _In_opt_ CNode *pNext)
Definition: atlcoll.h:818
Definition: Node.h:13
union node Node
Definition: types.h:1255
Definition: dlist.c:348

Referenced by START_TEST().

◆ AddTail()

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

◆ 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 818 of file atlcoll.h.

823{
824 GetFreeNode();
825
826 CNode* NewNode = m_FreeNode;
827 CNode* NextFree = m_FreeNode->m_Next;
828
829 NewNode = new CNode(element);
830
831 m_FreeNode = NextFree;
832 NewNode->m_Prev = Prev;
833 NewNode->m_Next = Next;
835
836 return NewNode;
837}
CNode * GetFreeNode()
Definition: atlcoll.h:856

◆ Find()

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

Definition at line 771 of file atlcoll.h.

774{
775 CNode* Node = (CNode*)posStartAfter;
776 if (Node == NULL)
777 {
779 }
780 else
781 {
782 Node = Node->m_Next;
783 }
784
785 for (; Node != NULL; Node = Node->m_Next)
786 {
787 if (ETraits::CompareElements(Node->m_Element, element))
788 return (POSITION)Node;
789 }
790
791 return NULL;
792}

Referenced by CMainWindow::AddApplicationsToView(), and CMainWindow::ItemCheckStateChanged().

◆ FindIndex()

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

Definition at line 795 of file atlcoll.h.

796{
797 if (iElement >= m_NumElements)
798 return NULL;
799
800 if (m_HeadNode == NULL)
801 return NULL;
802
804 for (size_t i = 0; i < iElement; i++)
805 {
806 Node = Node->m_Next;
807 }
808
809 return (POSITION)Node;
810}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

◆ FreeNode()

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

Definition at line 840 of file atlcoll.h.

843{
844 pNode->~CNode();
845 pNode->m_Next = m_FreeNode;
846 m_FreeNode = pNode;
847
849 if (m_NumElements == 0)
850 {
851 RemoveAll();
852 }
853}

◆ GetAt() [1/2]

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

Definition at line 593 of file atlcoll.h.

594{
595 CNode* Node = (CNode*)pos;
596 return Node->m_Element;
597}

◆ GetAt() [2/2]

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

Definition at line 600 of file atlcoll.h.

601{
602 CNode* Node = (CNode*)pos;
603 return Node->m_Element;
604}

◆ GetCount()

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

Definition at line 537 of file atlcoll.h.

538{
539 return m_NumElements;
540}

Referenced by CFontCache::Read(), START_TEST(), and CMainWindow::UpdateStatusBarText().

◆ GetFreeNode()

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

Definition at line 856 of file atlcoll.h.

857{
858 if (m_FreeNode)
859 {
860 return m_FreeNode;
861 }
862
864 if (Block == NULL)
865 {
867 }
868
869 CNode* Node = (CNode*)Block->GetData();
870 Node += (m_BlockSize - 1);
871 for (int i = m_BlockSize - 1; i >= 0; i--)
872 {
873 Node->m_Next = m_FreeNode;
875 Node--;
876 }
877
878 return m_FreeNode;
879}
static CAtlPlex * Create(_Inout_ CAtlPlex *&Entry, _In_ size_t MaxElements, _In_ size_t ElementSize)
Definition: atlcoll.h:35
void * GetData()
Definition: atlcoll.h:58
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
void AtlThrowImp(HRESULT hr)
Definition: atlexcept.h:18

◆ GetHeadPosition()

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

◆ GetNext() [1/2]

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

Definition at line 561 of file atlcoll.h.

562{
563 CNode* Node = (CNode*)pos;
564 pos = (POSITION)Node->m_Next;
565 return Node->m_Element;
566}
#define POSITION

Referenced by DownloadListOfApplications(), CAppDB::FindByPackageName(), CFontCache::Insert(), LoadAllSettings(), CFontCache::Read(), SaveAllSettings(), and START_TEST().

◆ GetNext() [2/2]

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

Definition at line 569 of file atlcoll.h.

570{
571 CNode* Node = (CNode*)pos;
572 pos = (POSITION)Node->m_Next;
573 return Node->m_Element;
574}

◆ GetPrev() [1/2]

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

Definition at line 577 of file atlcoll.h.

578{
579 CNode* Node = (CNode*)pos;
580 pos = (POSITION)Node->m_Prev;
581 return Node->m_Element;
582}

◆ GetPrev() [2/2]

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

Definition at line 585 of file atlcoll.h.

586{
587 CNode* Node = (CNode*)pos;
588 pos = (POSITION)Node->m_Prev;
589 return Node->m_Element;
590}

◆ GetTailPosition()

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

Definition at line 555 of file atlcoll.h.

556{
557 return (POSITION)m_TailNode;
558}

◆ InsertAfter()

template<typename E , class ETraits = CElementTraits<E>>
POSITION ATL::CAtlList< E, ETraits >::InsertAfter ( _In_ POSITION  pos,
INARGTYPE  element 
)

Definition at line 703 of file atlcoll.h.

704{
705 if (pos == NULL)
706 return AddTail(element);
707
708 CNode* OldNode = (CNode*)pos;
709 CNode* Node = CreateNode(element, OldNode, OldNode->m_Next);
710
711 if (OldNode->m_Next != NULL)
712 {
713 OldNode->m_Next->m_Prev = Node;
714 }
715 else
716 {
718 }
719 OldNode->m_Next = Node;
720
721 return (POSITION)Node;
722}
POSITION AddTail(INARGTYPE element)
Definition: atlcoll.h:624

Referenced by START_TEST().

◆ InsertBefore()

template<typename E , class ETraits = CElementTraits<E>>
POSITION ATL::CAtlList< E, ETraits >::InsertBefore ( _In_ POSITION  pos,
INARGTYPE  element 
)

Definition at line 681 of file atlcoll.h.

682{
683 if (pos == NULL)
684 return AddHead(element);
685
686 CNode* OldNode = (CNode*)pos;
687 CNode* Node = CreateNode(element, OldNode->m_Prev, OldNode);
688
689 if (OldNode->m_Prev != NULL)
690 {
691 OldNode->m_Prev->m_Next = Node;
692 }
693 else
694 {
696 }
697 OldNode->m_Prev = Node;
698
699 return (POSITION)Node;
700}
POSITION AddHead(INARGTYPE element)
Definition: atlcoll.h:607

Referenced by CFontCache::Insert(), and START_TEST().

◆ IsEmpty()

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

Definition at line 543 of file atlcoll.h.

544{
545 return (m_NumElements == 0);
546}

Referenced by DownloadListOfApplications(), and CMainWindow::OnCommand().

◆ 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 725 of file atlcoll.h.

726{
727 while (m_NumElements > 0)
728 {
731 FreeNode(Node);
732 }
733
737
738 if (m_Blocks)
739 {
740 m_Blocks->Destroy();
741 m_Blocks = NULL;
742 }
743}
void FreeNode(_Inout_ CNode *pNode)
Definition: atlcoll.h:840
void Destroy()
Definition: atlcoll.h:63

Referenced by CMainWindow::OnCommand(), and CMainWindow::UpdateApplicationsList().

◆ RemoveAt()

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

Definition at line 746 of file atlcoll.h.

747{
748 ATLASSERT(pos != NULL);
749
750 CNode* OldNode = (CNode*)pos;
751 if (OldNode == m_HeadNode)
752 {
753 m_HeadNode = OldNode->m_Next;
754 }
755 else
756 {
757 OldNode->m_Prev->m_Next = OldNode->m_Next;
758 }
759 if (OldNode == m_TailNode)
760 {
761 m_TailNode = OldNode->m_Prev;
762 }
763 else
764 {
765 OldNode->m_Next->m_Prev = OldNode->m_Prev;
766 }
767 FreeNode(OldNode);
768}

Referenced by CMainWindow::ItemCheckStateChanged().

◆ RemoveHead()

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

Definition at line 641 of file atlcoll.h.

642{
644 E Element(Node->m_Element);
645
646 m_HeadNode = Node->m_Next;
647 if (m_HeadNode)
648 {
650 }
651 else
652 {
654 }
655 FreeNode(Node);
656
657 return Element;
658}
static const WCHAR E[]
Definition: oid.c:1253

◆ RemoveTail()

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

Definition at line 661 of file atlcoll.h.

662{
664 E Element(Node->m_Element);
665
666 m_TailNode = Node->m_Prev;
667 if (m_TailNode)
668 {
670 }
671 else
672 {
674 }
675 FreeNode(Node);
676
677 return Element;
678}

Member Data Documentation

◆ m_Blocks

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

Definition at line 450 of file atlcoll.h.

◆ m_BlockSize

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

Definition at line 451 of file atlcoll.h.

◆ m_FreeNode

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

Definition at line 454 of file atlcoll.h.

◆ m_HeadNode

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

Definition at line 452 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 455 of file atlcoll.h.

◆ m_TailNode

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

Definition at line 453 of file atlcoll.h.


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