ReactOS 0.4.15-dev-8109-gd7be748
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
 
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 521 of file atlcoll.h.

521 :
522 m_Blocks(NULL),
523 m_BlockSize(nBlockSize),
528{
529 ATLASSERT(nBlockSize > 0);
530}
#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 533 of file atlcoll.h.

534{
535 RemoveAll();
536}
void RemoveAll()
Definition: atlcoll.h:727

Member Function Documentation

◆ AddHead()

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

Definition at line 609 of file atlcoll.h.

610{
612 if (m_HeadNode)
613 {
615 }
616 else
617 {
619 }
621
622 return (POSITION)Node;
623}
CNode * CreateNode(INARGTYPE element, _In_opt_ CNode *pPrev, _In_opt_ CNode *pNext)
Definition: atlcoll.h:859
Definition: Node.h:13
union node Node
Definition: types.h:1255
Definition: dlist.c:348

Referenced by test_BasicCases().

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

864{
865 GetFreeNode();
866
867 CNode* NewNode = m_FreeNode;
868 CNode* NextFree = m_FreeNode->m_Next;
869
870 NewNode = new CNode(element);
871
872 m_FreeNode = NextFree;
873 NewNode->m_Prev = Prev;
874 NewNode->m_Next = Next;
876
877 return NewNode;
878}
CNode * GetFreeNode()
Definition: atlcoll.h:897

◆ Find()

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

Definition at line 773 of file atlcoll.h.

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

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

798{
799 if (iElement >= m_NumElements)
800 return NULL;
801
802 if (m_HeadNode == NULL)
803 return NULL;
804
806 for (size_t i = 0; i < iElement; i++)
807 {
808 Node = Node->m_Next;
809 }
810
811 return (POSITION)Node;
812}
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 881 of file atlcoll.h.

884{
885 pNode->~CNode();
886 pNode->m_Next = m_FreeNode;
887 m_FreeNode = pNode;
888
890 if (m_NumElements == 0)
891 {
892 RemoveAll();
893 }
894}

◆ GetAt() [1/2]

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

Definition at line 595 of file atlcoll.h.

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

◆ GetAt() [2/2]

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

Definition at line 602 of file atlcoll.h.

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

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

898{
899 if (m_FreeNode)
900 {
901 return m_FreeNode;
902 }
903
905 if (Block == NULL)
906 {
908 }
909
910 CNode* Node = (CNode*)Block->GetData();
911 Node += (m_BlockSize - 1);
912 for (int i = m_BlockSize - 1; i >= 0; i--)
913 {
914 Node->m_Next = m_FreeNode;
916 Node--;
917 }
918
919 return m_FreeNode;
920}
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 571 of file atlcoll.h.

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

◆ GetPrev() [1/2]

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

Definition at line 579 of file atlcoll.h.

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

◆ GetPrev() [2/2]

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

Definition at line 587 of file atlcoll.h.

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

◆ GetTailPosition()

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

Definition at line 557 of file atlcoll.h.

558{
559 return (POSITION)m_TailNode;
560}

◆ InsertAfter()

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

Definition at line 705 of file atlcoll.h.

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

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

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

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

◆ IsEmpty()

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

Definition at line 545 of file atlcoll.h.

546{
547 return (m_NumElements == 0);
548}

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

728{
729 while (m_NumElements > 0)
730 {
733 FreeNode(Node);
734 }
735
739
740 if (m_Blocks)
741 {
742 m_Blocks->Destroy();
743 m_Blocks = NULL;
744 }
745}
void FreeNode(_Inout_ CNode *pNode)
Definition: atlcoll.h:881
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 748 of file atlcoll.h.

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

Referenced by CMainWindow::ItemCheckStateChanged().

◆ RemoveHead()

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

Definition at line 643 of file atlcoll.h.

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

◆ RemoveTail()

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

Definition at line 663 of file atlcoll.h.

664{
666 E Element(Node->m_Element);
667
668 m_TailNode = Node->m_Prev;
669 if (m_TailNode)
670 {
672 }
673 else
674 {
676 }
677 FreeNode(Node);
678
679 return Element;
680}

◆ SwapElements()

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

Definition at line 815 of file atlcoll.h.

816{
817 if (pos1 == pos2)
818 return;
819
820
821 CNode *node1 = (CNode *)pos1;
822 CNode *node2 = (CNode *)pos2;
823
824 CNode *tmp = node1->m_Prev;
825 node1->m_Prev = node2->m_Prev;
826 node2->m_Prev = tmp;
827
828 if (node1->m_Prev)
829 node1->m_Prev->m_Next = node1;
830 else
831 m_HeadNode = node1;
832
833 if (node2->m_Prev)
834 node2->m_Prev->m_Next = node2;
835 else
836 m_HeadNode = node2;
837
838 tmp = node1->m_Next;
839 node1->m_Next = node2->m_Next;
840 node2->m_Next = tmp;
841
842 if (node1->m_Next)
843 node1->m_Next->m_Prev = node1;
844 else
845 m_TailNode = node1;
846
847 if (node2->m_Next)
848 node2->m_Next->m_Prev = node2;
849 else
850 m_TailNode = node2;
851}

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: