"L. Spiro Engine"
Classes | Public Types | Public Member Functions | Protected Attributes

lstl::CMap Class Reference

Inheritance diagram for lstl::CMap:
lstl::CMapBase

List of all members.

Classes

struct  LSTL_PAIR

Public Types

typedef struct
lstl::CMap::LSTL_PAIR
LPLSTL_PAIR
typedef struct
lstl::CMap::LSTL_PAIR 
LPCLSTL_PAIR

Public Member Functions

LSE_CALL CMap (const CMap< _tKeyType, _tMappedType > &_mSrc)
LSE_CALL CMap (CAllocator *_paAllocator)
_tMappedType &LSE_CALL operator[] (const _tKeyType &_tKey)
const _tMappedType &LSE_CALL operator[] (const _tKeyType &_tKey) const
CMap< _tKeyType, _tMappedType >
&LSE_CALL 
operator= (const CMap< _tKeyType, _tMappedType > &_mSrc)
LSBOOL LSE_CALL Allocate (LSUINT32 _ui32Total)
LSBOOL LSE_CALL Insert (const LSTL_PAIR *_ppPairs, LSUINT32 _ui32Total)
LSBOOL LSE_CALL Insert (const LSTL_PAIR &_pPair, _tMappedType **_pptReturnValue=NULL)
LSBOOL LSE_CALL Insert (const _tKeyType &_tKey, const _tMappedType &_tValue, _tMappedType **_pptReturnValue=NULL)
LSVOID LSE_CALL RemoveNoDealloc (const _tKeyType *_ptKeys, LSUINT32 _ui32Total)
LSVOID LSE_CALL RemoveNoDealloc (const _tKeyType &_tKey)
LSVOID LSE_CALL Remove (const _tKeyType *_ptKeys, LSUINT32 _ui32Total)
LSVOID LSE_CALL Remove (const _tKeyType &_tKey)
LSVOID LSE_CALL RemoveByIndex (LSUINT32 _ui32Index)
LSVOID LSE_CALL RemoveByIndexNoDealloc (LSUINT32 _ui32Index)
LSVOID LSE_CALL ResetNoDealloc ()
LSVOID LSE_CALL Reset ()
LSUINT32 LSE_CALL Length () const
_tMappedType &LSE_CALL GetByIndex (LSUINT32 _ui32Index)
const _tMappedType &LSE_CALL GetByIndex (LSUINT32 _ui32Index) const
_tKeyType &LSE_CALL GetKeyByIndex (LSUINT32 _ui32Index)
const _tKeyType &LSE_CALL GetKeyByIndex (LSUINT32 _ui32Index) const
LSBOOL LSE_CALL GetItemIndex (const _tKeyType &_tKey, LSUINT32 &_ui32Index) const
LSBOOL LSE_CALL ItemExists (const _tKeyType &_tKey) const
LSBOOL LSE_CALL ItemExists (const _tKeyType &_tKey, LSUINT32 &_ui32Index) const
LSVOID LSE_CALL SetAllocator (CAllocator *_paAllocator)
CAllocator *LSE_CALL GetAllocator ()

Protected Attributes

CVector< LSTL_PAIR, LSUINT32, 1024UL > m_vPairs

Member Typedef Documentation

Our internal representation of the mapped values. These are sorted by key.


Member Function Documentation

LSBOOL LSE_CALL lstl::CMap::Allocate ( LSUINT32  _ui32Total) [inline]

Allocate a given number of elements. If the allocation is less than what there already is, items are removed.

Parameters:
_ui32TotalNumber of elements to allocate.
Returns:
Returns true if there was enough memory to allocate the given amount of objects. If _ui32Total is 0, true is always returned.
CAllocator* LSE_CALL lstl::CMap::GetAllocator ( ) [inline]

Get our allocator.

Returns:
Returns a pointer to the allocator used by this object.
_tMappedType& LSE_CALL lstl::CMap::GetByIndex ( LSUINT32  _ui32Index) [inline]

Get a mapped value by index. Values are always sorted by their respective keys.

Parameters:
_ui32IndexThe index of the mapped value to get, which must be valid.
Returns:
Returns a reference to the mapped value at the given index inside this map.
const _tMappedType& LSE_CALL lstl::CMap::GetByIndex ( LSUINT32  _ui32Index) const [inline]

Get a mapped value by index. Values are always sorted by their respective keys.

Parameters:
_ui32IndexThe index of the mapped value to get, which must be valid.
Returns:
Returns a reference to the mapped value at the given index inside this map.
LSBOOL LSE_CALL lstl::CMap::GetItemIndex ( const _tKeyType &  _tKey,
LSUINT32 &  _ui32Index 
) const [inline]

Get the index of an existing item. If the item does not exist, the index indicates where it should be if it did exist.

Parameters:
_tKeyKey of the item to find.
_ui32IndexThe returned index of the found item or the index where the item should be inserted.
Returns:
Returns true if the item exists, false otherwise.
_tKeyType& LSE_CALL lstl::CMap::GetKeyByIndex ( LSUINT32  _ui32Index) [inline]

Get a key value by index.

Parameters:
_ui32IndexThe index of the key value to get, which must be valid.
Returns:
Returns a reference to the key value at the given index inside this map.
const _tKeyType& LSE_CALL lstl::CMap::GetKeyByIndex ( LSUINT32  _ui32Index) const [inline]

Get a key value by index.

Parameters:
_ui32IndexThe index of the key value to get, which must be valid.
Returns:
Returns a reference to the key value at the given index inside this map.
LSBOOL LSE_CALL lstl::CMap::Insert ( const LSTL_PAIR _ppPairs,
LSUINT32  _ui32Total 
) [inline]

Insert an array of pairs of keys and mapped values. Any keys that exist will not be modified.

Parameters:
_ppPairsThe pairs to insert.
_ui32TotalThe total number of pairs to insert.
Returns:
Returns true if the items were added or already existed. A return of false always indicates a memory failure.
LSBOOL LSE_CALL lstl::CMap::Insert ( const LSTL_PAIR _pPair,
_tMappedType **  _pptReturnValue = NULL 
) [inline]

Insert a single pair of a key and its mapped value. If the key exists, it is not modified.

Parameters:
_pPairThe pair to insert.
_pptReturnValueThe returned mapped value.
Returns:
Returns true if the item was added or already exists. A return of false always indicates a memory failure.
LSBOOL LSE_CALL lstl::CMap::Insert ( const _tKeyType &  _tKey,
const _tMappedType &  _tValue,
_tMappedType **  _pptReturnValue = NULL 
) [inline]

Insert a single pair of a key and its mapped value. If the key exists, it is not modified.

Parameters:
_tKeyThe pair's key.
_tValueThe pair's mapped value.
_pptReturnValueThe returned mapped value.
Returns:
Returns true if the item was added or already exists. A return of false always indicates a memory failure.
LSBOOL LSE_CALL lstl::CMap::ItemExists ( const _tKeyType &  _tKey,
LSUINT32 &  _ui32Index 
) const [inline]

Determines whether the given key already exists in the map or not and, if so, returns the index of the item.

Parameters:
_tKeyThe key to test for existance in the map.
_ui32IndexThe index of the item in the map, if it exists.
Returns:
Returns true if the item key is already in the map, false otherwise.
LSBOOL LSE_CALL lstl::CMap::ItemExists ( const _tKeyType &  _tKey) const [inline]

Determines whether the given key already exists in the map or not.

Parameters:
_tKeyThe key to test for existance in the map.
Returns:
Returns true if the item key is already in the map, false otherwise.
LSUINT32 LSE_CALL lstl::CMap::Length ( ) const [inline]

Get the total number of items.

Returns:
Returns the total pairs in the map.
CMap<_tKeyType, _tMappedType>& LSE_CALL lstl::CMap::operator= ( const CMap< _tKeyType, _tMappedType > &  _mSrc) [inline]

Copy another map into this one. Each element in the source map is copied. The allocator is not copied, meaning the new CMap does not use the same allocator as the original.

Parameters:
_mSrcThe map of which to make a copy.
Returns:
Returns a reference to this object after the copy.
const _tMappedType& LSE_CALL lstl::CMap::operator[] ( const _tKeyType &  _tKey) const [inline]

Access a mapped value by its key. If the given key does not exist, it is added and its default mapped value is returned. Throws an exception if a memory failure prevents the adding of a key.

Parameters:
_tKeyThe key of the value to find.
Returns:
Returns the mapped value associated with the given key.
_tMappedType& LSE_CALL lstl::CMap::operator[] ( const _tKeyType &  _tKey) [inline]

Access a mapped value by its key. If the given key does not exist, it is added and its default mapped value is returned. Throws an exception if a memory failure prevents the adding of a key.

Parameters:
_tKeyThe key of the value to find.
Returns:
Returns the mapped value associated with the given key.
LSVOID LSE_CALL lstl::CMap::Remove ( const _tKeyType &  _tKey) [inline]

Remove a pair.

Parameters:
_tKeyThe key of the pair to remove.
LSVOID LSE_CALL lstl::CMap::Remove ( const _tKeyType *  _ptKeys,
LSUINT32  _ui32Total 
) [inline]

Remove an array of items.

Parameters:
_ptKeysThe keys of the items to remove.
_ui32TotalThe total number of pairs to remove.
LSVOID LSE_CALL lstl::CMap::RemoveByIndex ( LSUINT32  _ui32Index) [inline]

Remove by index.

Parameters:
_ui32IndexIndex of the pair to remove.
LSVOID LSE_CALL lstl::CMap::RemoveByIndexNoDealloc ( LSUINT32  _ui32Index) [inline]

Remove by index without deallocating.

Parameters:
_ui32IndexIndex of the pair to remove.
LSVOID LSE_CALL lstl::CMap::RemoveNoDealloc ( const _tKeyType *  _ptKeys,
LSUINT32  _ui32Total 
) [inline]

Remove an array of items without reallocating.

Parameters:
_ptKeysThe keys of the items to remove.
_ui32TotalThe total number of pairs to remove.
LSVOID LSE_CALL lstl::CMap::RemoveNoDealloc ( const _tKeyType &  _tKey) [inline]

Remove a pair without reallocating.

Parameters:
_tKeyThe key of the pair to remove.
LSVOID LSE_CALL lstl::CMap::Reset ( ) [inline]

Reset all contents.

LSVOID LSE_CALL lstl::CMap::ResetNoDealloc ( ) [inline]

Reset without reallocating.

LSVOID LSE_CALL lstl::CMap::SetAllocator ( CAllocator _paAllocator) [inline]

Set the allocator. Causes the object to be fully reset. Should not be used on lists that have contents already.

Parameters:
_paAllocatorThe new allocator to be used by this object or NULL to use the default allocator for map objects.

Member Data Documentation

CVector<LSTL_PAIR, LSUINT32, 1024UL> lstl::CMap::m_vPairs [protected]

Our internal array of paired items.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator