ReactOS 0.4.16-dev-136-g52192f1
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)
 
void AddHeadList (_In_ const CAtlList< E, ETraits > *plNew)
 
void AddTailList (_In_ const CAtlList< E, ETraits > *plNew)
 
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
 
void SwapElements (POSITION pos1, POSITION pos2)
 

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

524 :
525 m_Blocks(NULL),
526 m_BlockSize(nBlockSize),
531{
532 ATLASSERT(nBlockSize > 0);
533}
#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 536 of file atlcoll.h.

537{
538 RemoveAll();
539}
void RemoveAll()
Definition: atlcoll.h:748

Member Function Documentation

◆ AddHead()

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

Definition at line 612 of file atlcoll.h.

613{
615 if (m_HeadNode)
616 {
618 }
619 else
620 {
622 }
624
625 return (POSITION)Node;
626}
CNode * CreateNode(INARGTYPE element, _In_opt_ CNode *pPrev, _In_opt_ CNode *pNext)
Definition: atlcoll.h:880
Definition: Node.h:13
union node Node
Definition: types.h:1255
Definition: dlist.c:348

Referenced by EditTypeDlg_OnCommand(), and test_BasicCases().

◆ AddHeadList()

template<typename E , class ETraits >
void ATL::CAtlList< E, ETraits >::AddHeadList ( _In_ const CAtlList< E, ETraits > *  plNew)

Definition at line 646 of file atlcoll.h.

647{
648 ATLASSERT(plNew != NULL && plNew != this);
649 POSITION pos = plNew->GetTailPosition();
650 while (pos)
651 AddHead(plNew->GetPrev(pos));
652}
POSITION AddHead(INARGTYPE element)
Definition: atlcoll.h:612

◆ AddTail()

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

◆ AddTailList()

template<typename E , class ETraits >
void ATL::CAtlList< E, ETraits >::AddTailList ( _In_ const CAtlList< E, ETraits > *  plNew)

Definition at line 655 of file atlcoll.h.

656{
657 ATLASSERT(plNew != NULL && plNew != this);
658 POSITION pos = plNew->GetHeadPosition();
659 while (pos)
660 AddTail(plNew->GetNext(pos));
661}
POSITION AddTail(INARGTYPE element)
Definition: atlcoll.h:629

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

885{
886 GetFreeNode();
887
888 CNode* NewNode = m_FreeNode;
889 CNode* NextFree = m_FreeNode->m_Next;
890
891 NewNode = new CNode(element);
892
893 m_FreeNode = NextFree;
894 NewNode->m_Prev = Prev;
895 NewNode->m_Next = Next;
897
898 return NewNode;
899}
CNode * GetFreeNode()
Definition: atlcoll.h:918

◆ Find()

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

Definition at line 794 of file atlcoll.h.

797{
798 CNode* Node = (CNode*)posStartAfter;
799 if (Node == NULL)
800 {
802 }
803 else
804 {
805 Node = Node->m_Next;
806 }
807
808 for (; Node != NULL; Node = Node->m_Next)
809 {
810 if (ETraits::CompareElements(Node->m_Element, element))
811 return (POSITION)Node;
812 }
813
814 return NULL;
815}

Referenced by CMainWindow::AddApplicationsToView(), EditTypeDlg_WriteClass(), CMainWindow::ItemCheckStateChanged(), and CZipEnumerator::next_unique().

◆ FindIndex()

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

Definition at line 818 of file atlcoll.h.

819{
820 if (iElement >= m_NumElements)
821 return NULL;
822
823 if (m_HeadNode == NULL)
824 return NULL;
825
827 for (size_t i = 0; i < iElement; i++)
828 {
829 Node = Node->m_Next;
830 }
831
832 return (POSITION)Node;
833}
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 902 of file atlcoll.h.

905{
906 pNode->~CNode();
907 pNode->m_Next = m_FreeNode;
908 m_FreeNode = pNode;
909
911 if (m_NumElements == 0)
912 {
913 RemoveAll();
914 }
915}

◆ GetAt() [1/2]

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

Definition at line 598 of file atlcoll.h.

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

◆ GetAt() [2/2]

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

Definition at line 605 of file atlcoll.h.

606{
607 CNode* Node = (CNode*)pos;
608 return Node->m_Element;
609}

◆ GetCount()

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

◆ GetFreeNode()

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

Definition at line 918 of file atlcoll.h.

919{
920 if (m_FreeNode)
921 {
922 return m_FreeNode;
923 }
924
926 if (Block == NULL)
927 {
929 }
930
931 CNode* Node = (CNode*)Block->GetData();
932 Node += (m_BlockSize - 1);
933 for (int i = m_BlockSize - 1; i >= 0; i--)
934 {
935 Node->m_Next = m_FreeNode;
937 Node--;
938 }
939
940 return m_FreeNode;
941}
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

◆ GetNext() [2/2]

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

Definition at line 574 of file atlcoll.h.

575{
576 CNode* Node = (CNode*)pos;
577 pos = (POSITION)Node->m_Next;
578 return Node->m_Element;
579}

◆ GetPrev() [1/2]

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

Definition at line 582 of file atlcoll.h.

583{
584 CNode* Node = (CNode*)pos;
585 pos = (POSITION)Node->m_Prev;
586 return Node->m_Element;
587}

◆ GetPrev() [2/2]

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

Definition at line 590 of file atlcoll.h.

591{
592 CNode* Node = (CNode*)pos;
593 pos = (POSITION)Node->m_Prev;
594 return Node->m_Element;
595}

◆ GetTailPosition()

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

Definition at line 560 of file atlcoll.h.

561{
562 return (POSITION)m_TailNode;
563}

◆ InsertAfter()

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

Definition at line 726 of file atlcoll.h.

727{
728 if (pos == NULL)
729 return AddTail(element);
730
731 CNode* OldNode = (CNode*)pos;
732 CNode* Node = CreateNode(element, OldNode, OldNode->m_Next);
733
734 if (OldNode->m_Next != NULL)
735 {
736 OldNode->m_Next->m_Prev = Node;
737 }
738 else
739 {
741 }
742 OldNode->m_Next = Node;
743
744 return (POSITION)Node;
745}

Referenced by test_BasicCases().

◆ InsertBefore()

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

Definition at line 704 of file atlcoll.h.

705{
706 if (pos == NULL)
707 return AddHead(element);
708
709 CNode* OldNode = (CNode*)pos;
710 CNode* Node = CreateNode(element, OldNode->m_Prev, OldNode);
711
712 if (OldNode->m_Prev != NULL)
713 {
714 OldNode->m_Prev->m_Next = Node;
715 }
716 else
717 {
719 }
720 OldNode->m_Prev = Node;
721
722 return (POSITION)Node;
723}

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

◆ IsEmpty()

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

Definition at line 548 of file atlcoll.h.

549{
550 return (m_NumElements == 0);
551}

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

749{
750 while (m_NumElements > 0)
751 {
754 FreeNode(Node);
755 }
756
760
761 if (m_Blocks)
762 {
763 m_Blocks->Destroy();
764 m_Blocks = NULL;
765 }
766}
void FreeNode(_Inout_ CNode *pNode)
Definition: atlcoll.h:902
void Destroy()
Definition: atlcoll.h:63

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

◆ RemoveAt()

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

Definition at line 769 of file atlcoll.h.

770{
771 ATLASSERT(pos != NULL);
772
773 CNode* OldNode = (CNode*)pos;
774 if (OldNode == m_HeadNode)
775 {
776 m_HeadNode = OldNode->m_Next;
777 }
778 else
779 {
780 OldNode->m_Prev->m_Next = OldNode->m_Next;
781 }
782 if (OldNode == m_TailNode)
783 {
784 m_TailNode = OldNode->m_Prev;
785 }
786 else
787 {
788 OldNode->m_Next->m_Prev = OldNode->m_Prev;
789 }
790 FreeNode(OldNode);
791}

Referenced by CMainWindow::ItemCheckStateChanged().

◆ RemoveHead()

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

Definition at line 664 of file atlcoll.h.

665{
667 E Element(Node->m_Element);
668
669 m_HeadNode = Node->m_Next;
670 if (m_HeadNode)
671 {
673 }
674 else
675 {
677 }
678 FreeNode(Node);
679
680 return Element;
681}
static const WCHAR E[]
Definition: oid.c:1253

◆ RemoveTail()

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

Definition at line 684 of file atlcoll.h.

685{
687 E Element(Node->m_Element);
688
689 m_TailNode = Node->m_Prev;
690 if (m_TailNode)
691 {
693 }
694 else
695 {
697 }
698 FreeNode(Node);
699
700 return Element;
701}

◆ SwapElements()

template<typename E , class ETraits >
void ATL::CAtlList< E, ETraits >::SwapElements ( POSITION  pos1,
POSITION  pos2 
)

Definition at line 836 of file atlcoll.h.

837{
838 if (pos1 == pos2)
839 return;
840
841
842 CNode *node1 = (CNode *)pos1;
843 CNode *node2 = (CNode *)pos2;
844
845 CNode *tmp = node1->m_Prev;
846 node1->m_Prev = node2->m_Prev;
847 node2->m_Prev = tmp;
848
849 if (node1->m_Prev)
850 node1->m_Prev->m_Next = node1;
851 else
852 m_HeadNode = node1;
853
854 if (node2->m_Prev)
855 node2->m_Prev->m_Next = node2;
856 else
857 m_HeadNode = node2;
858
859 tmp = node1->m_Next;
860 node1->m_Next = node2->m_Next;
861 node2->m_Next = tmp;
862
863 if (node1->m_Next)
864 node1->m_Next->m_Prev = node1;
865 else
866 m_TailNode = node1;
867
868 if (node2->m_Next)
869 node2->m_Next->m_Prev = node2;
870 else
871 m_TailNode = node2;
872}

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: