ReactOS  0.4.12-dev-36-g472787f
ATL::CSimpleArray< T, TEqual > Class Template Reference

#include <atlsimpcoll.h>

Collaboration diagram for ATL::CSimpleArray< T, TEqual >:

Classes

struct  ConstructImpl
 

Public Types

typedef T _ArrayElementType
 

Public Member Functions

 CSimpleArray ()
 
 CSimpleArray (const CSimpleArray< T, TEqual > &src)
 
 ~CSimpleArray ()
 
BOOL Add (const T &t)
 
int Find (const T &t) const
 
TGetData ()
 
const TGetData () const
 
int GetSize () const
 
BOOL Remove (const T &t)
 
void RemoveAll ()
 
BOOL RemoveAt (int nIndex)
 
BOOL SetAtIndex (int nIndex, const T &t)
 
Toperator[] (int nIndex)
 
const Toperator[] (int nIndex) const
 
CSimpleArray< T, TEqual > & operator= (const CSimpleArray< T, TEqual > &src)
 

Protected Member Functions

void ConstructItemInPlace (int nIndex, const T &src)
 
void DestructItem (int nIndex)
 

Protected Attributes

Tm_pData
 
int m_nCount
 
int m_nCapacity
 

Static Protected Attributes

static const int c_nGrow = 8
 

Detailed Description

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
class ATL::CSimpleArray< T, TEqual >

Definition at line 38 of file atlsimpcoll.h.

Member Typedef Documentation

◆ _ArrayElementType

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
typedef T ATL::CSimpleArray< T, TEqual >::_ArrayElementType

Definition at line 41 of file atlsimpcoll.h.

Constructor & Destructor Documentation

◆ CSimpleArray() [1/2]

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
ATL::CSimpleArray< T, TEqual >::CSimpleArray ( )
inline

Definition at line 43 of file atlsimpcoll.h.

43  : m_pData(NULL), m_nCount(0), m_nCapacity(0)
44  {
45  }
smooth NULL
Definition: ftsmooth.c:416

◆ CSimpleArray() [2/2]

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
ATL::CSimpleArray< T, TEqual >::CSimpleArray ( const CSimpleArray< T, TEqual > &  src)
inline

Definition at line 47 of file atlsimpcoll.h.

47  :
49  {
50  *this = src;
51  }
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
smooth NULL
Definition: ftsmooth.c:416

◆ ~CSimpleArray()

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
ATL::CSimpleArray< T, TEqual >::~CSimpleArray ( )
inline

Definition at line 53 of file atlsimpcoll.h.

54  {
55  RemoveAll();
56  }

Member Function Documentation

◆ Add()

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
BOOL ATL::CSimpleArray< T, TEqual >::Add ( const T t)
inline

Definition at line 58 of file atlsimpcoll.h.

Referenced by cb_AddPage(), EnumHotpluggedDevices(), EnumWindowsProc(), CAvailableApps::FindInfoList(), CAppsListView::GetCheckedItems(), CAvailableApps::GetSelected(), CAvailableApplicationInfo::RetrieveLanguages(), and UseCmdParameters().

59  {
60  // is the capacity enough?
61  if (m_nCapacity < m_nCount + 1)
62  {
63  // allocate extra capacity for optimization
64  const int nNewCapacity = (m_nCount + 1) + c_nGrow;
65  T *pNewData = (T *)realloc(m_pData, nNewCapacity * sizeof(T));
66  if (pNewData == NULL)
67  return FALSE; // failure
68 
69  m_pData = pNewData;
70  m_nCapacity = nNewCapacity;
71  }
72 
73  // call constructor
75 
76  // increment
77  ++m_nCount;
78 
79  return TRUE;
80  }
#define realloc
Definition: debug_ros.c:6
#define TRUE
Definition: types.h:120
GLdouble GLdouble t
Definition: gl.h:2047
#define T
Definition: mbstring.h:31
smooth NULL
Definition: ftsmooth.c:416
static const int c_nGrow
Definition: atlsimpcoll.h:218
void ConstructItemInPlace(int nIndex, const T &src)
Definition: atlsimpcoll.h:226

◆ ConstructItemInPlace()

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
void ATL::CSimpleArray< T, TEqual >::ConstructItemInPlace ( int  nIndex,
const T src 
)
inlineprotected

Definition at line 226 of file atlsimpcoll.h.

227  {
228  new(&m_pData[nIndex]) ConstructImpl(src);
229  }
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
int nIndex
Definition: msvc.h:77

◆ DestructItem()

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
void ATL::CSimpleArray< T, TEqual >::DestructItem ( int  nIndex)
inlineprotected

Definition at line 232 of file atlsimpcoll.h.

233  {
234  m_pData[nIndex].~T();
235  }
int nIndex
Definition: msvc.h:77

◆ Find()

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
int ATL::CSimpleArray< T, TEqual >::Find ( const T t) const
inline

Definition at line 82 of file atlsimpcoll.h.

83  {
84  for (int nIndex = 0; nIndex < m_nCount; ++nIndex)
85  {
87  {
88  return nIndex; // success
89  }
90  }
91  return -1; // failure
92  }
GLdouble GLdouble t
Definition: gl.h:2047
int nIndex
Definition: msvc.h:77

◆ GetData() [1/2]

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
T* ATL::CSimpleArray< T, TEqual >::GetData ( )
inline

Definition at line 94 of file atlsimpcoll.h.

95  {
96  return m_pData;
97  }

◆ GetData() [2/2]

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
const T* ATL::CSimpleArray< T, TEqual >::GetData ( ) const
inline

Definition at line 99 of file atlsimpcoll.h.

100  {
101  return m_pData;
102  }

◆ GetSize()

◆ operator=()

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
CSimpleArray<T, TEqual>& ATL::CSimpleArray< T, TEqual >::operator= ( const CSimpleArray< T, TEqual > &  src)
inline

Definition at line 175 of file atlsimpcoll.h.

176  {
177  // don't copy if two objects are same
178  if (this == &src)
179  return *this;
180 
181  if (src.GetSize() != GetSize())
182  {
183  RemoveAll();
184 
185  int nNewCount = src.GetSize();
186 
187  T *pNewData = (T *)realloc(m_pData, nNewCount * sizeof(T));
188  ATLASSERT(pNewData);
189  if (pNewData == NULL)
190  return *this; // failure
191 
192  // store new
193  m_pData = pNewData;
194  m_nCount = nNewCount;
195  m_nCapacity = nNewCount;
196  }
197  else
198  {
199  for (int nIndex = 0; nIndex < m_nCount; ++nIndex)
200  {
202  }
203  }
204 
205  ATLASSERT(GetSize() == src.GetSize());
206  for (int nIndex = 0; nIndex < src.GetSize(); ++nIndex)
207  {
209  }
210 
211  return *this;
212  }
#define realloc
Definition: debug_ros.c:6
#define ATLASSERT(x)
Definition: CComVariant.cpp:9
int GetSize() const
Definition: atlsimpcoll.h:104
#define T
Definition: mbstring.h:31
smooth NULL
Definition: ftsmooth.c:416
int nIndex
Definition: msvc.h:77
void DestructItem(int nIndex)
Definition: atlsimpcoll.h:232
void ConstructItemInPlace(int nIndex, const T &src)
Definition: atlsimpcoll.h:226

◆ operator[]() [1/2]

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
T& ATL::CSimpleArray< T, TEqual >::operator[] ( int  nIndex)
inline

Definition at line 163 of file atlsimpcoll.h.

164  {
165  ATLASSERT(0 <= nIndex && nIndex < m_nCount);
166  return m_pData[nIndex];
167  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:9
int nIndex
Definition: msvc.h:77

◆ operator[]() [2/2]

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
const T& ATL::CSimpleArray< T, TEqual >::operator[] ( int  nIndex) const
inline

Definition at line 169 of file atlsimpcoll.h.

170  {
171  ATLASSERT(0 <= nIndex && nIndex < m_nCount);
172  return m_pData[nIndex];
173  }
#define ATLASSERT(x)
Definition: CComVariant.cpp:9
int nIndex
Definition: msvc.h:77

◆ Remove()

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
BOOL ATL::CSimpleArray< T, TEqual >::Remove ( const T t)
inline

Definition at line 109 of file atlsimpcoll.h.

110  {
111  return RemoveAt(Find(t));
112  }
GLdouble GLdouble t
Definition: gl.h:2047
BOOL RemoveAt(int nIndex)
Definition: atlsimpcoll.h:132
int Find(const T &t) const
Definition: atlsimpcoll.h:82

◆ RemoveAll()

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
void ATL::CSimpleArray< T, TEqual >::RemoveAll ( )
inline

Definition at line 114 of file atlsimpcoll.h.

Referenced by EnumHotpluggedDevices(), CTrayWindow::RestoreAll(), and WaitWindows().

115  {
116  if (m_pData)
117  {
118  // call destructor
119  const int nCount = m_nCount;
120  for (int nIndex = 0; nIndex < nCount; ++nIndex)
121  {
123  }
124 
125  free(m_pData);
126  m_pData = NULL;
127  }
128  m_nCount = 0;
129  m_nCapacity = 0;
130  }
#define free
Definition: debug_ros.c:5
smooth NULL
Definition: ftsmooth.c:416
int nIndex
Definition: msvc.h:77
void DestructItem(int nIndex)
Definition: atlsimpcoll.h:232

◆ RemoveAt()

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
BOOL ATL::CSimpleArray< T, TEqual >::RemoveAt ( int  nIndex)
inline

Definition at line 132 of file atlsimpcoll.h.

Referenced by _ShowContextMenu().

133  {
134  // boundary check
135  if (nIndex < 0 || m_nCount <= nIndex)
136  return FALSE; // failure
137 
138  // call destructor
140 
141  // move range [nIndex + 1, m_nCount) to nIndex
142  const int nRightCount = m_nCount - (nIndex + 1);
143  const int nRightSize = nRightCount * sizeof(T);
144  memmove(&m_pData[nIndex], &m_pData[nIndex + 1], nRightSize);
145 
146  // decrement
147  --m_nCount;
148 
149  return TRUE;
150  }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
#define T
Definition: mbstring.h:31
int nIndex
Definition: msvc.h:77
void DestructItem(int nIndex)
Definition: atlsimpcoll.h:232

◆ SetAtIndex()

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
BOOL ATL::CSimpleArray< T, TEqual >::SetAtIndex ( int  nIndex,
const T t 
)
inline

Definition at line 152 of file atlsimpcoll.h.

153  {
154  // boundary check
155  if (nIndex < 0 || m_nCount <= nIndex)
156  return FALSE; // failure
157 
158  // store it
159  m_pData[nIndex] = t;
160  return TRUE;
161  }
#define TRUE
Definition: types.h:120
GLdouble GLdouble t
Definition: gl.h:2047
int nIndex
Definition: msvc.h:77

Member Data Documentation

◆ c_nGrow

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
const int ATL::CSimpleArray< T, TEqual >::c_nGrow = 8
staticprotected

Definition at line 218 of file atlsimpcoll.h.

◆ m_nCapacity

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
int ATL::CSimpleArray< T, TEqual >::m_nCapacity
protected

Definition at line 217 of file atlsimpcoll.h.

◆ m_nCount

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
int ATL::CSimpleArray< T, TEqual >::m_nCount
protected

Definition at line 216 of file atlsimpcoll.h.

◆ m_pData

template<typename T, typename TEqual = CSimpleArrayEqualHelper<T>>
T* ATL::CSimpleArray< T, TEqual >::m_pData
protected

Definition at line 215 of file atlsimpcoll.h.


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