ReactOS 0.4.16-dev-401-g45b008d
ATL::CSimpleMap< TKey, TVal, TEqual > Class Template Reference

#include <atlsimpcoll.h>

Collaboration diagram for ATL::CSimpleMap< TKey, TVal, TEqual >:

Classes

struct  Pair
 

Public Types

typedef TKey _ArrayKeyType
 
typedef TVal _ArrayElementType
 

Public Member Functions

 CSimpleMap ()
 
 ~CSimpleMap ()
 
BOOL Add (const TKey &key, const TVal &val)
 
int FindKey (const TKey &key) const
 
int FindVal (const TVal &val) const
 
TKey & GetKeyAt (int nIndex)
 
const TKey & GetKeyAt (int nIndex) const
 
int GetSize () const
 
TVal & GetValueAt (int nIndex)
 
const TVal & GetValueAt (int nIndex) const
 
TVal Lookup (const TKey &key) const
 
BOOL Remove (const TKey &key)
 
void RemoveAll ()
 
BOOL RemoveAt (int nIndex)
 
TKey ReverseLookup (const TVal &val) const
 
BOOL SetAt (const TKey &key, const TVal &val)
 
BOOL SetAtIndex (int nIndex, const TKey &key, const TVal &val)
 

Protected Attributes

CSimpleArray< Pair, CSimpleArrayEqualHelperFalse< Pair > > m_Pairs
 

Detailed Description

template<typename TKey, typename TVal, typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
class ATL::CSimpleMap< TKey, TVal, TEqual >

Definition at line 295 of file atlsimpcoll.h.

Member Typedef Documentation

◆ _ArrayElementType

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
typedef TVal ATL::CSimpleMap< TKey, TVal, TEqual >::_ArrayElementType

Definition at line 299 of file atlsimpcoll.h.

◆ _ArrayKeyType

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
typedef TKey ATL::CSimpleMap< TKey, TVal, TEqual >::_ArrayKeyType

Definition at line 298 of file atlsimpcoll.h.

Constructor & Destructor Documentation

◆ CSimpleMap()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
ATL::CSimpleMap< TKey, TVal, TEqual >::CSimpleMap ( )
inline

Definition at line 301 of file atlsimpcoll.h.

302 {
303 }

◆ ~CSimpleMap()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
ATL::CSimpleMap< TKey, TVal, TEqual >::~CSimpleMap ( )
inline

Definition at line 305 of file atlsimpcoll.h.

306 {
307 }

Member Function Documentation

◆ Add()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
BOOL ATL::CSimpleMap< TKey, TVal, TEqual >::Add ( const TKey &  key,
const TVal &  val 
)
inline

Definition at line 309 of file atlsimpcoll.h.

310 {
311 Pair pair(key, val);
312 return m_Pairs.Add(pair);
313 }
CSimpleArray< Pair, CSimpleArrayEqualHelperFalse< Pair > > m_Pairs
Definition: atlsimpcoll.h:449
GLuint GLfloat * val
Definition: glext.h:7180
Definition: copy.c:22
Definition: _pair.h:47

Referenced by CConfigParser::ReadSection(), and ATL::CSimpleMap< TKey, TVal, TEqual >::SetAt().

◆ FindKey()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
int ATL::CSimpleMap< TKey, TVal, TEqual >::FindKey ( const TKey &  key) const
inline

Definition at line 315 of file atlsimpcoll.h.

316 {
317 const int nCount = GetSize();
318 for (int nIndex = 0; nIndex < nCount; ++nIndex)
319 {
320 if (TEqual::IsEqualKey(m_Pairs[nIndex].key, key))
321 {
322 return nIndex; // success
323 }
324 }
325 return -1; // failure
326 }
int GetSize() const
Definition: atlsimpcoll.h:353

Referenced by EditTypeDlg_OnCommand(), EditTypeDlg_WriteClass(), CConfigParser::GetString(), ATL::CSimpleMap< TKey, TVal, TEqual >::Lookup(), CConfigParser::ReadSection(), ATL::CSimpleMap< TKey, TVal, TEqual >::Remove(), and ATL::CSimpleMap< TKey, TVal, TEqual >::SetAt().

◆ FindVal()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
int ATL::CSimpleMap< TKey, TVal, TEqual >::FindVal ( const TVal &  val) const
inline

Definition at line 328 of file atlsimpcoll.h.

329 {
330 const int nCount = GetSize();
331 for (int nIndex = 0; nIndex < nCount; ++nIndex)
332 {
333 if (TEqual::IsEqualValue(m_Pairs[nIndex].val, val))
334 {
335 return nIndex; // success
336 }
337 }
338 return -1; // failure
339 }

Referenced by ATL::CSimpleMap< TKey, TVal, TEqual >::ReverseLookup().

◆ GetKeyAt() [1/2]

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
TKey & ATL::CSimpleMap< TKey, TVal, TEqual >::GetKeyAt ( int  nIndex)
inline

Definition at line 341 of file atlsimpcoll.h.

342 {
343 ATLASSERT(0 <= nIndex && nIndex < GetSize());
344 return m_Pairs[nIndex].key;
345 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10

Referenced by EditTypeDlg_WriteClass().

◆ GetKeyAt() [2/2]

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
const TKey & ATL::CSimpleMap< TKey, TVal, TEqual >::GetKeyAt ( int  nIndex) const
inline

Definition at line 347 of file atlsimpcoll.h.

348 {
349 ATLASSERT(0 <= nIndex && nIndex < GetSize());
350 return m_Pairs[nIndex].key;
351 }

◆ GetSize()

◆ GetValueAt() [1/2]

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
TVal & ATL::CSimpleMap< TKey, TVal, TEqual >::GetValueAt ( int  nIndex)
inline

Definition at line 358 of file atlsimpcoll.h.

359 {
360 ATLASSERT(0 <= nIndex && nIndex < GetSize());
361 return m_Pairs[nIndex].val;
362 }

Referenced by EditTypeDlg_OnCommand(), EditTypeDlg_WriteClass(), and CConfigParser::GetString().

◆ GetValueAt() [2/2]

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
const TVal & ATL::CSimpleMap< TKey, TVal, TEqual >::GetValueAt ( int  nIndex) const
inline

Definition at line 364 of file atlsimpcoll.h.

365 {
366 ATLASSERT(0 <= nIndex && nIndex < GetSize());
367 return m_Pairs[nIndex].val;
368 }

◆ Lookup()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
TVal ATL::CSimpleMap< TKey, TVal, TEqual >::Lookup ( const TKey &  key) const
inline

Definition at line 370 of file atlsimpcoll.h.

371 {
372 int nIndex = FindKey(key);
373 if (nIndex < 0)
374 return TVal();
375 return m_Pairs[nIndex].val;
376 }
int FindKey(const TKey &key) const
Definition: atlsimpcoll.h:315

◆ Remove()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
BOOL ATL::CSimpleMap< TKey, TVal, TEqual >::Remove ( const TKey &  key)
inline

Definition at line 378 of file atlsimpcoll.h.

379 {
380 int nIndex = FindKey(key);
381 return RemoveAt(nIndex);
382 }
BOOL RemoveAt(int nIndex)
Definition: atlsimpcoll.h:389

Referenced by EditTypeDlg_OnRemove().

◆ RemoveAll()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
void ATL::CSimpleMap< TKey, TVal, TEqual >::RemoveAll ( )
inline

Definition at line 384 of file atlsimpcoll.h.

385 {
386 m_Pairs.RemoveAll();
387 }

◆ RemoveAt()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
BOOL ATL::CSimpleMap< TKey, TVal, TEqual >::RemoveAt ( int  nIndex)
inline

Definition at line 389 of file atlsimpcoll.h.

390 {
391 return m_Pairs.RemoveAt(nIndex);
392 }

Referenced by ATL::CSimpleMap< TKey, TVal, TEqual >::Remove().

◆ ReverseLookup()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
TKey ATL::CSimpleMap< TKey, TVal, TEqual >::ReverseLookup ( const TVal &  val) const
inline

Definition at line 394 of file atlsimpcoll.h.

395 {
396 int nIndex = FindVal(val);
397 if (nIndex < 0)
398 return TKey();
399 return m_Pairs[nIndex].key;
400 }
int FindVal(const TVal &val) const
Definition: atlsimpcoll.h:328

◆ SetAt()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
BOOL ATL::CSimpleMap< TKey, TVal, TEqual >::SetAt ( const TKey &  key,
const TVal &  val 
)
inline

Definition at line 402 of file atlsimpcoll.h.

403 {
404 int nIndex = FindKey(key);
405 if (nIndex < 0)
406 return Add(key, val);
407
408 m_Pairs[nIndex].val = val;
409 return TRUE;
410 }
BOOL Add(const TKey &key, const TVal &val)
Definition: atlsimpcoll.h:309
#define TRUE
Definition: types.h:120

Referenced by EditTypeDlg_OnCommand(), and EditTypeDlg_ReadClass().

◆ SetAtIndex()

template<typename TKey , typename TVal , typename TEqual = CSimpleMapEqualHelper<TKey, TVal>>
BOOL ATL::CSimpleMap< TKey, TVal, TEqual >::SetAtIndex ( int  nIndex,
const TKey &  key,
const TVal &  val 
)
inline

Definition at line 412 of file atlsimpcoll.h.

413 {
414 // boundary check
415 if (nIndex < 0 || GetSize() <= nIndex)
416 return FALSE;
417
418 m_Pairs[nIndex].key = key;
419 m_Pairs[nIndex].val = val;
420 return TRUE;
421 }
#define FALSE
Definition: types.h:117

Member Data Documentation

◆ m_Pairs


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