"L. Spiro Engine"
Classes | Typedefs | Enumerations | Functions | Variables

lstl Namespace Reference

Classes

class  CAllocator
 Basic allocation methods. More...
class  CLinkedListBase
 Provides a default allocator for the CLinkedList class. More...
class  CSingleLinkedList
 A template providing linked-list functionality. More...
class  CMap
class  CMapBase
 Provides a default allocator shared among all instances of CMap classes. More...
class  CMultiMap
class  CMultiMapBase
 Provides a default allocator shared among all instances of CMultiMap classes. More...
class  CResourceManCrtp
class  CSetBase
 Provides a default allocator shared among all instances of CMap classes. More...
class  CSharedPtr
 A standard shared pointer. More...
class  CStringBase
class  CStringListBase
 An array of strings with some useful additions.. More...
class  CWString
 A standard string class with an optional allocator. More...
class  CSVectorCrtp
 A basic vector. More...
class  CSVectorPoD
class  CSVector8
class  CSVector16
class  CSVector32
class  CVector
 A vector class that works on all types that follow the rule of 3. More...
class  CVectorBase
class  CVectorPoD
 Adds the ability to supply a specific allocator to a simple vector. More...

Typedefs

typedef CLinkedListBase Parent

Enumerations

enum  LSSTL_SHARED_PTR { LSSTL_SP_MAKE_NEW }
enum  LSTL_STRING_EXCEPTIONS { LSTL_SE_OUTOFMEMORY }

Functions

m_lpllnTail (NULL)
LSVOID LSE_CALL SetAllocator (CAllocator *_paAllocator)
CAllocator *LSE_CALL GetAllocator ()
LSVOID LSE_CALL Reset ()
LPLSTL_LINKED_LIST_NODE LSE_CALL InsertAfter (const _tType &_tNew, LPLSTL_LINKED_LIST_NODE _lpllnNode)
LSVOID LSE_CALL RemoveItem (LPLSTL_LINKED_LIST_NODE _lpllnNode)
LPLSTL_LINKED_LIST_NODE LSE_CALL Head ()
LPLSTL_LINKED_LIST_NODE LSE_CALL Tail ()
LPLSTL_LINKED_LIST_NODE LSE_CALL PushFront (const _tType &_tNew)
LPLSTL_LINKED_LIST_NODE LSE_CALL PushBack (const _tType &_tNew)
LSUINT32 LSE_CALL Length ()
LPLSTL_LINKED_LIST_NODE LSE_CALL Find (const _tType &_tValue)
LSVOID LSE_CALL Construct (LSTL_LINKED_LIST_NODE &_llnNode)
LSVOID LSE_CALL Destroy (const LSTL_LINKED_LIST_NODE &_llnNode)
LPLSTL_LINKED_LIST_NODE LSE_CALL NewNode ()
LSBOOL LSE_CALL AllocateAtLeast (LSUINT32 _ui32Size)
LSBOOL LSE_CALL Insert (const _tKeyType *_ptKeys, LSUINT32 _ui32Total)
LSBOOL LSE_CALL Insert (const _tKeyType &_tKey)
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 ResetNoDealloc ()
const _tKeyType &LSE_CALL GetByIndex (LSUINT32 _ui32Index) const
LSBOOL LSE_CALL ItemExists (const _tKeyType &_tKey) const
LSBOOL LSE_CALL GetItemIndex (const _tKeyType &_tKey, LSUINT32 &_ui32Index) const

Variables

__pad0__
_tDataType
*const LPCLSTL_LINKED_LIST_NODE
LPLSTL_LINKED_LIST_NODE m_lpllnHead
LPLSTL_LINKED_LIST_NODE m_lpllnTail
CAllocatorm_paOurAllocator
_tKeyType
return * this
CVector< _tKeyType, LSUINT32 > m_vKeys

Detailed Description

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Algorithms related to our templates.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Provide a base interface for allocation. All objects in this library use this when they want to allocate RAM. Inherit from this and modify the Alloc, ReAlloc, and Free functions, then pass your class to the templates in this library to make them use your allocation methods instead.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A template providing linked-list functionality. The list is doubly linked.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Provides a default allocator for the CLinkedList class.

Copyright L. Spiro 2012 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A template providing linked-list functionality. The list is one-way.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: An associative container pairing a unique key with a mapped value. The key and value do not need to be of the same type.

Values are accessed via their keys, so each key is unique. Mapped values do not need to be unique. Mapped values are sorted, and the key type must implement the == and < operators.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Provides a default allocator shared among all instances of CMap classes.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: An associative container in which multiple values may share the same keys. This similar to CMap, except that a CMap allows only one key/value pair. A multimap supports key/[value/value/value/...] associations.

Because keys are sorted, the key type must implement the == and < operators.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Provides a default allocator shared among all instances of CMultiMap classes.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A standard resource manager. It requires a key and a resource type, and manages resources of the given type, ensuring redundant copies do not exist. It is basically a wrapper around a CMap. The resource type must be in the form of a shared pointer.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: An associate container such that each element is the key itself. CMap's associate keys with values, whereas CSet simply keeps a list of keys. Like with CMap, each key is unique in the list, and sorted by key value. Because keys are sorted, the key type must implement the == and < operators.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Provides a default allocator shared among all instances of CSet classes.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A standard shared pointer.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A standard string class with an optional allocator. Simply specializes the CStringBase template with a char. In this way, this class provides an example of how to create a string of any base type (char wchar_t, unsigned short, etc.)

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A list of regular char-sized strings.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: An array of strings with some useful additions.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A standard wide-character string class with an optional allocator. Simply specializes the CStringBase template with a wchar_t. In this way, this class provides an example of how to create a string of any base type (char, wchar_t, unsigned short, etc.)

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A list of wchar_t-sized strings.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: We use the Curious Recurring Template Pattern to change how Allocate() works between different versions of the vectors, since virtual functions are not allowed on templates. This class provides the base members for all vector instances (which is different from CVectorBase, which provides static members that vector instances share) and uses _tDerivedType to cast the object to the correct type before calling functions. Read about Curious Recurring Template Pattern if you do not understand the logic behind this. This class cannot be instantiated directly!

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A simple vector. It gives direct array access for the same speed as any array, but the sizes of the vector allocation counters can be specified, allowing for arrays of limited length but few bytes vs. arrays of large lengths but requiring more memory. Additionally, the vectors save valuable space by allocating linearly as it grows rather than doubling in size each time. The amount by which it grows can be specified. This vector also cleans up after itself when removing items from the list. When the list is less than half the allocated length the allocation is adjusted to half of what it is. Note that the whole point of this template is to be as small as possible to save as much space as possible. Consider a vector of a vector where the outer vector can be large and uses 32-bit indices while the inner vector is small enough to use 8-bit indices and saves 6 bytes of RAM for every index in the outer vector. Because of this focus on size, there is no allocator pointer in this template. Instead, we add limited support for allocators with a macro that, when defined, uses CMemLib for allocation instead of the standard C functions. This makes it possible to use the template with an allocator from this set of libraries, but it will only allocate from the main pool. Luckily, this is enough for most situations. If you strictly must allocate from a specific pool, you will implicitly have to sacrifice the size of your vector object, and a CVectorPoD should be used instead.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Extends the CSVectorCrtp class to mke it work properly with types that are not plain data. Use this for types that have a complicated destructor, copy constructor, and copy assignment operator.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A common base class used for all types of vectors. This does not add any size to the vector; it simply adds a static default allocator. If this were added to the template classes then each type of vector would get its own copy of the default allocators, but really there should be only this one. This organization is done specifically so that CSVectorPoD types can remain small, since their focus is directly on size. In exchange for the small size of the CSVectorPoD template, flexibility is lost in that all CSVectorPoD types use the same allocator. You cannot have some CSVectorPoD types use one pool of RAM while another set uses another.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Inherits from a simple vector and adds a member that allows defining an allocator. In order to use the allocator the Allocate() and Reset() functions are replaced. This vector should be used only for plain data types.


Enumeration Type Documentation

A single enumerated value that lets the shared pointer know to create a new object within its constructor.


Function Documentation

LSBOOL LSE_CALL lstl::AllocateAtLeast ( LSUINT32  _ui32Size)

Allocates room for at least the given amount of items. If the allocation size is already larger than the given amount, nothing is done.

Parameters:
_ui32SizeThe minimum number of items to allocate.
Returns:
Returns true if the allocation was successful.
LSVOID LSE_CALL lstl::Construct ( LSTL_LINKED_LIST_NODE &  _llnNode) [protected]

Secret way of constructing items.

Parameters:
_llnNodeThe item to be constructed.
LSVOID LSE_CALL lstl::Destroy ( const LSTL_LINKED_LIST_NODE &  _llnNode) [protected]

Secret way of destroying items. No error checking.

Parameters:
_llnNodeThe item to be destroyed.
LPLSTL_LINKED_LIST_NODE LSE_CALL lstl::Find ( const _tType &  _tValue)

Finds the linked-list entry containing the given value.

Parameters:
_tValueThe value to find.
Returns:
Returns a pointer to the linked-list entry with the given value or NULL.
CAllocator *LSE_CALL lstl::GetAllocator ( )

Gets our allocator.

Returns:
Returns our allocator.

Get our allocator.

Returns:
Returns a pointer to the allocator used by this object.
const _tKeyType& LSE_CALL lstl::GetByIndex ( LSUINT32  _ui32Index) const

Get a key for read-only by index.

Parameters:
_ui32IndexThe index of the key to get, which must be valid.
Returns:
Returns a reference to the key at the given index inside this set.
LSBOOL LSE_CALL lstl::GetItemIndex ( const _tKeyType &  _tKey,
LSUINT32 &  _ui32Index 
) const

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.
LPLSTL_LINKED_LIST_NODE LSE_CALL lstl::Head ( )

Gets the head of this list.

Returns:
Returns the head of the linked list, which may be NULL.
LSBOOL LSE_CALL lstl::Insert ( const _tKeyType *  _ptKeys,
LSUINT32  _ui32Total 
)

Insert an array of keys.

Parameters:
_ptKeysThe keys to insert.
_ui32TotalThe total number of keys to insert.
Returns:
Returns true if the item was added or already exists. A return of false always indicates a memory failure.
LSBOOL LSE_CALL lstl::Insert ( const _tKeyType &  _tKey)

Insert a single key.

Parameters:
_tKeyThe key to insert.
Returns:
Returns true if the item was added or already exists. A return of false always indicates a memory failure.
LPLSTL_LINKED_LIST_NODE LSE_CALL lstl::InsertAfter ( const _tType &  _tNew,
LPLSTL_LINKED_LIST_NODE  _lpllnNode 
)

Insert an item after another item. If the previous item is NULL, the new item is inserted at the beginning of the list.

Parameters:
_tNewThe item to insert.
_lpllnNodeThe node after which the item is to be inserted or NULL.
Returns:
Returns the created node if insertion was successful. Returns NULL if allocation fails.
LSBOOL LSE_CALL lstl::ItemExists ( const _tKeyType &  _tKey) const

Determine if an item is in the list or not.

Parameters:
_tKeyKey of the item to find.
Returns:
Returns true if the item is in the list.
LSUINT32 LSE_CALL lstl::Length ( )

Gets the total number of items in the list.

Returns:
Returns the number of items in the linked list.

Get the total number of items.

Returns:
Returns the total pairs in the set.
LPLSTL_LINKED_LIST_NODE LSE_CALL lstl::NewNode ( ) [protected]

Create a new node.

Returns:
Returns a new node.
LPLSTL_LINKED_LIST_NODE LSE_CALL lstl::PushBack ( const _tType &  _tNew)

Insert at the tail of the list.

Parameters:
_tNewThe item to add to the list.
Returns:
Returns the created node if insertion was successful. Returns NULL if allocation fails.
LPLSTL_LINKED_LIST_NODE LSE_CALL lstl::PushFront ( const _tType &  _tNew)

Insert at the front of the list.

Parameters:
_tNewThe item to add to the list.
Returns:
Returns the created node if insertion was successful. Returns NULL if allocation fails.
LSVOID LSE_CALL lstl::Remove ( const _tKeyType &  _tKey)

Remove a pair.

Parameters:
_tKeyThe key to remove.
LSVOID LSE_CALL lstl::Remove ( const _tKeyType *  _ptKeys,
LSUINT32  _ui32Total 
)

Remove an array of items.

Parameters:
_ptKeysThe keys to remove.
_ui32TotalThe total number of keys to remove.
LSVOID LSE_CALL lstl::RemoveItem ( LPLSTL_LINKED_LIST_NODE  _lpllnNode)

Remove an item from the linked list. The item is deleted upon being removed and the item pointer may no longer be used.

Parameters:
_lpllnNodeThe node to remove from this linked list.
LSVOID LSE_CALL lstl::RemoveNoDealloc ( const _tKeyType *  _ptKeys,
LSUINT32  _ui32Total 
)

Remove an array of items without reallocating.

Parameters:
_ptKeysThe keys to remove.
_ui32TotalThe total number of keys to remove.
LSVOID LSE_CALL lstl::RemoveNoDealloc ( const _tKeyType &  _tKey)

Remove a key without reallocating.

Parameters:
_tKeyThe key to remove.
LSVOID LSE_CALL lstl::Reset ( )

Reset everything. Clears all resources created by this instance.

Reset all contents.

LSVOID LSE_CALL lstl::ResetNoDealloc ( )

Reset without reallocating.

LSVOID LSE_CALL lstl::SetAllocator ( CAllocator *  _paAllocator)

Set the allocator to be used by this instance. Causes the object to be fully reset. Cannot be used on lists that have contents already.

Parameters:
_paAllocatorPointer to the allocator to use.

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 set objects.
LPLSTL_LINKED_LIST_NODE LSE_CALL lstl::Tail ( )

Gets the tail of this list.

Returns:
Returns the head of the linked list, which may be NULL.

Variable Documentation

LPLSTL_LINKED_LIST_NODE lstl::m_lpllnHead

The head of the list.

LPLSTL_LINKED_LIST_NODE lstl::m_lpllnTail

The tail of the list.

The allocator we should use.

CVector<_tKeyType, LSUINT32> lstl::m_vKeys

Our internal array of paired items.

 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator