CLList Class ReferenceProvides simple sortable linked list.
More...
#include <LList.h>
Inheritance diagram for CLList:
[legend]Collaboration diagram for CLList:
[legend]List of all members.
|
Public Member Functions |
| virtual void * | Find (DWORD user) |
| virtual void * | IFind (LPCTSTR pKey) |
| | Searches for a list element matching the specified key string.
|
| virtual void * | Find (const void *pKey, DWORD dwKey=0) |
| | Searches for a matching binary key.
|
| virtual BOOL | InitObject (void *node) |
| | Initializes a list element.
|
| virtual void | DeleteObject (void *node) |
| | Destroys a single list element.
|
| virtual void * | New (const void *init=NULL, DWORD dwUser=0, const void *pKey=NULL, DWORD dwKeySize=0) |
| | Creates a new list element.
|
| void * | SetObject (void *obj, const void *init=NULL, DWORD dwUser=0, const void *pKey=NULL, DWORD dwKeySize=0) |
| | Sets the data inside a list element.
|
| void * | ResetObject (void *obj, const void *init=NULL, DWORD dwUser=0, const void *pKey=NULL, DWORD dwKeySize=0) |
|
virtual void | Destroy () |
| | Deletes all elements in the list.
|
| void | Init (BOOL bDestroy=TRUE) |
| | Initializes the CLList object.
|
| virtual DWORD | GetObjSize () |
| | Provides the size of a single list element structure.
|
| void | Zero (void *ptr, DWORD size) |
| | Initializes the custom portion of a list element.
|
| BOOL | MoveToBottom (void *ptr) |
| | Moves the specified element to the bottom of the list.
|
| BOOL | MoveToTop (void *ptr) |
| | Moves the specified element to the top of the list.
|
| BOOL | Append (void *ptr, void *after) |
| | Appends the specified element after another node in the list.
|
| BOOL | Insert (void *ptr, void *before) |
| | Inserts the specified element before another node in the list.
|
| BOOL | MoveDown (void *ptr) |
| | Moves a list element down one position in the list.
|
| BOOL | MoveUp (void *ptr) |
| | Moves an element up one position in the list.
|
| virtual void | Delete (void *ptr, BOOL bDelete=TRUE) |
| | Removes an element from the list.
|
|
| CLList () |
| | Constructor.
|
|
virtual | ~CLList () |
| | Destructor.
|
| void * | Put (DWORD dw) |
| | Inserts a DWORD value into the list.
|
| void * | Put (LPVOID pVal, DWORD size) |
| | Inserts a binary buffer value into the list.
|
| void * | Put (LPCTSTR pStr) |
| | Inserts a string into the list.
|
| LPCTSTR | GetKeyStr (void *ptr) |
| | Returns the key string for a list element.
|
| LPBYTE | GetKeyPtr (void *ptr) |
| | Returns a pointer to the binary key data for a list element.
|
| DWORD | GetKeySize (void *ptr) |
| | Number of bytes in the list element key.
|
| virtual const void * | SetKey (void *ptr, const void *pKey, DWORD dwKeySize=0) |
| | Sets a binary buffer to use as a list element key.
|
|
void | DeleteAllItems () |
| | Removes all list elements.
|
| void * | NewObj (DWORD dwSize, const void *init=NULL, DWORD dwUser=0, const void *pKey=NULL, DWORD dwKeySize=0) |
| | Creates and initializes a new list element without inserting.
|
| void * | FindByUserData (DWORD data) |
| | Searches the list for an element with matching user value.
|
| void | ReleaseStr (LPSTR *pBuf) |
| | Releases a previously allocated string.
|
| LPCTSTR | AllocateStr (LPSTR *pBuf, LPCTSTR pStr) |
| | Allocates a buffer for a string and initializes.
|
| void | ReleaseObject (void *node) |
| | Releases resources allocated for a single list element.
|
| virtual void * | VerifyPointer (void *ptr) |
| | Verifys that a pointer is valid by searching for a match in the list.
|
| virtual void * | GetByIndex (DWORD i) |
| | Retrieves a list element by its position in the list.
|
| BOOL | Randomize (DWORD seed, DWORD loops=1) |
| | Randomizes the position of all list elements.
|
| BOOL | Link (LPLLISTINFO *list, DWORD size) |
| | Reliniks a list element array.
|
| long | Compare (LPLLISTINFO p1, LPLLISTINFO p2) |
| | Compares two list items to determine which should come first.
|
| void | rQuickSort (LPLLISTINFO *list, DWORD left, DWORD right) |
| | Provies a recursive quick sort.
|
| BOOL | QuickSort (LPLLISTINFO *list, DWORD left, DWORD right) |
| | Provides a non-recursive quick sort.
|
| BOOL | QuickSort (BOOL bRecursive=TRUE) |
| | Performs a quick sort on the list.
|
| virtual DWORD | Load (LPBYTE buf, DWORD size, BOOL bMerge=FALSE) |
| | Loads binary formated list from memory buffer.
|
| virtual DWORD | Save (LPBYTE buf, DWORD size) |
| | Saves binary formated list into a memory buffer.
|
| virtual DWORD | Load (LPCTSTR pFile, BOOL bMerge=FALSE) |
| | Loads binary formated list from disk file.
|
| virtual DWORD | Save (LPCTSTR pFile) |
| | Writes binary encoded list to a disk file.
|
|
DWORD | Size () |
| | Returns the number of elements in the list.
|
| void * | GetNext (void *ptr) |
| | Returns the next list item, use for enumerating the list forward.
|
| void * | GetPrev (void *ptr) |
| | Returns the previous list item, use for enumerating the list backward.
|
| void | SetUserData (void *ptr, DWORD data) |
| | Sets the user DWORD value into a list element.
|
| DWORD | GetUserData (void *ptr) |
| | Returns the user DWORD value in a list element.
|
|
| operator CTlLock & () |
| | Returns pointer to the thread lock.
|
|
CTlLock * | GetLock () |
| | Returns pointer to the thread lock.
|
Detailed Description
Provides simple sortable linked list.
This class is very old but provides basic linked list functionality. For new code, use ATL7 classes if available. If you need random access ability, use CHList instead.
Member Function Documentation
| LPCTSTR CLList::AllocateStr |
( |
LPSTR * |
pBuf, |
|
|
LPCTSTR |
pStr |
|
) |
|
|
|
|
Allocates a buffer for a string and initializes.
- Parameters:
-
| [in] | pBuf | - Receives pointer to buffer |
| [in] | pStr | - Pointer to initial value of string |
- Returns:
- Pointer to newly allocated string buffer
- See also:
|
| BOOL CLList::Append |
( |
void * |
ptr, |
|
|
void * |
after |
|
) |
|
|
|
|
Appends the specified element after another node in the list.
- Parameters:
-
| [in] | ptr | - Pointer to element to append |
| [in] | after | - Node after which to append |
- Returns:
- Non-zero if success
- See also:
|
|
|
Compares two list items to determine which should come first.
- Parameters:
-
| [in] | p1 | - First list element |
| [in] | p2 | - Second list element |
- Returns:
- 1 if p1 should come first, -1 if p2 should come first, 0 if equal
- See also:
|
| void CLList::Delete |
( |
void * |
ptr, |
|
|
BOOL |
bDelete = TRUE |
|
) |
[virtual] |
|
|
|
Removes an element from the list.
- Parameters:
-
| [in] | ptr | - Pointer to list element |
| [in] | bDelete | - Set to non-zero to destroy the element |
If bDelete is zero, the list element is removed from the list, but not destroyed. It may then be inserted at another point in the list. |
| void CLList::DeleteObject |
( |
void * |
node |
) |
[virtual] |
|
|
|
Destroys a single list element.
- Parameters:
-
| [in] | node | - Pointer to list element |
Over-ride to provide custom list element destruction
- See also:
- InitObject()
Reimplemented in CErrLog, CHList, CParams, CReg, CRKey, CTask, THList< H, T >, TStrList< T >, TLList< T >, CVar, THList< DWORD, CStack >, THList< GUID, THList< DWORD, THList< GUID, CTimeout > > >, THList< GUID, CNetCom >, THList< GUID, CCallbackTarget >, THList< GUID, CMsgTarget >, and TLList< CFrame >. |
| void * CLList::Find |
( |
const void * |
pKey, |
|
|
DWORD |
dwKey = 0 |
|
) |
[virtual] |
|
|
|
Searches for a matching binary key.
- Parameters:
-
| [in] | pKey | - Key buffer |
| [in] | dwKey | - Number of bytes in pKey |
- Warning:
- This function is slow since it must traverse the list
- Returns:
- Pointer to list item if found, otherwise NULL
- See also:
Reimplemented in CHList. |
| void * CLList::Find |
( |
DWORD |
user |
) |
[virtual] |
|
|
|
- Parameters:
-
| [in] | user | - Searches for a list element based on a user DWORD value. |
- Warning:
- This function is slow since it must traverse the list
- Returns:
- Pointer to list item if found, otherwise NULL
- See also:
Reimplemented in CHList. |
| void * CLList::FindByUserData |
( |
DWORD |
data |
) |
|
|
|
|
Searches the list for an element with matching user value.
- Parameters:
-
| [in] | data | - User value to search for |
- Warning:
- This function is slow since it must traverse the list
- Returns:
- Pointer to list element or NULL if match not found.
- See also:
|
| void * CLList::GetByIndex |
( |
DWORD |
i |
) |
[virtual] |
|
|
|
Retrieves a list element by its position in the list.
- Parameters:
-
| [in] | i | - List element position |
- Warning:
- This function is slow since it must traverse the list
- Returns:
- Pointer to a list element or NULL if index was invalid
- See also:
|
| LPBYTE CLList::GetKeyPtr |
( |
void * |
ptr |
) |
[inline] |
|
|
|
Returns a pointer to the binary key data for a list element.
- Parameters:
-
| [in] | ptr | - Pointer to a list element |
- Returns:
- Pointer to the binary key data or NULL if none
- See also:
|
| DWORD CLList::GetKeySize |
( |
void * |
ptr |
) |
[inline] |
|
|
|
Number of bytes in the list element key.
- Parameters:
-
| [in] | ptr | - Pointer to a list element |
- Returns:
- Number of bytes in the list element key
- See also:
|
| LPCTSTR CLList::GetKeyStr |
( |
void * |
ptr |
) |
[inline] |
|
|
|
Returns the key string for a list element.
- Parameters:
-
| [in] | ptr | - Pointer to a list element |
- Returns:
- Pointer the the key string or NULL if none
- See also:
|
| void* CLList::GetNext |
( |
void * |
ptr |
) |
[inline] |
|
|
|
Returns the next list item, use for enumerating the list forward.
- Parameters:
-
| [in] | ptr | - Pointer to list element |
If ptr is NULL, the head element is returned.
Example:
- Returns:
- Next element or NULL if none.
- See also:
|
| virtual DWORD CLList::GetObjSize |
( |
|
) |
[inline, virtual] |
|
|
|
Provides the size of a single list element structure.
Over-ride this function and provide the size of your custom structure.
- Returns:
- The size of a single list element structure
Reimplemented in CErrLog, CFileSearch, CModule, CParams, CReg, CRKey, CTask, THList< H, T >, TStrList< T >, TLList< T >, CVar, THList< DWORD, CStack >, THList< GUID, THList< DWORD, THList< GUID, CTimeout > > >, THList< GUID, CNetCom >, THList< GUID, CCallbackTarget >, THList< GUID, CMsgTarget >, and TLList< CFrame >. |
| void* CLList::GetPrev |
( |
void * |
ptr |
) |
[inline] |
|
|
|
Returns the previous list item, use for enumerating the list backward.
- Parameters:
-
| [in] | ptr | - Pointer to list element |
If ptr is NULL, the tail element is returned.
Example:
- Returns:
- Previous element or NULL if none.
- See also:
|
| DWORD CLList::GetUserData |
( |
void * |
ptr |
) |
[inline] |
|
|
|
Returns the user DWORD value in a list element.
- Parameters:
-
| [in] | ptr | - Pointer to a list element |
- Returns:
- User DWORD value
- See also:
|
| void * CLList::IFind |
( |
LPCTSTR |
pKey |
) |
[virtual] |
|
|
|
Searches for a list element matching the specified key string.
- Parameters:
-
| [in] | pKey | - Case insensitive key to search for. |
- Warning:
- This function is slow since it must traverse the list
- Returns:
- Pointer to list item if found, otherwise NULL
- See also:
|
| void CLList::Init |
( |
BOOL |
bDestroy = TRUE |
) |
|
|
|
|
Initializes the CLList object.
- Parameters:
-
| [in] | bDestroy | - Set to non-zero to destroy existing list |
Reimplemented in CParams. |
| BOOL CLList::InitObject |
( |
void * |
node |
) |
[virtual] |
|
|
|
Initializes a list element.
- Parameters:
-
| [in] | node | - Pointer to list element |
Over-ride to provide custom list element initialization.
- Returns:
- Non-zero if success
- See also:
- DeleteObject()
Reimplemented in CErrLog, CHList, CReg, THList< H, T >, TStrList< T >, TLList< T >, THList< DWORD, CStack >, THList< GUID, THList< DWORD, THList< GUID, CTimeout > > >, THList< GUID, CNetCom >, THList< GUID, CCallbackTarget >, THList< GUID, CMsgTarget >, and TLList< CFrame >. |
| BOOL CLList::Insert |
( |
void * |
ptr, |
|
|
void * |
before |
|
) |
|
|
|
|
Inserts the specified element before another node in the list.
- Parameters:
-
| [in] | ptr | - Pointer to element that is inserted |
| [in] | before | - Node before which ptr is inserted |
- Returns:
- Non-zero if success
- See also:
|
|
|
Reliniks a list element array.
- Parameters:
-
| [in] | list | - List element array |
| [in] | size | - Size of the array in list |
- Returns:
- Non-zero if success
- See also:
|
| DWORD CLList::Load |
( |
LPCTSTR |
pFile, |
|
|
BOOL |
bMerge = FALSE |
|
) |
[virtual] |
|
|
|
Loads binary formated list from disk file.
- Parameters:
-
| [in] | pFile | - Disk filename |
| [in] | bMerge | - Non-zero to merge into current list |
- Returns:
- Number of bytes read from file
- See also:
Reimplemented in CParams, and CReg. |
| DWORD CLList::Load |
( |
LPBYTE |
buf, |
|
|
DWORD |
size, |
|
|
BOOL |
bMerge = FALSE |
|
) |
[virtual] |
|
|
|
Loads binary formated list from memory buffer.
- Parameters:
-
| [in] | buf | - Pointer to binary data |
| [in] | size | - Number of bytes in buf |
| [in] | bMerge | - Non-zero to merge into current list |
- Returns:
- Number of bytes read
- See also:
Reimplemented in CParams. |
| BOOL CLList::MoveDown |
( |
void * |
ptr |
) |
|
|
|
|
Moves a list element down one position in the list.
- Parameters:
-
| [in] | ptr | - Pointer to list element |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CLList::MoveToBottom |
( |
void * |
ptr |
) |
|
|
|
|
Moves the specified element to the bottom of the list.
- Parameters:
-
- Returns:
- Non-zero if success
- See also:
|
| BOOL CLList::MoveToTop |
( |
void * |
ptr |
) |
|
|
|
|
Moves the specified element to the top of the list.
- Parameters:
-
- Returns:
- Non-zero if success
- See also:
|
| BOOL CLList::MoveUp |
( |
void * |
ptr |
) |
|
|
|
|
Moves an element up one position in the list.
- Parameters:
-
| [in] | ptr | - Pointer to list element |
- Returns:
- Non-zero if success
- See also:
|
| void * CLList::New |
( |
const void * |
init = NULL, |
|
|
DWORD |
dwUser = 0, |
|
|
const void * |
pKey = NULL, |
|
|
DWORD |
dwKeySize = 0 |
|
) |
[virtual] |
|
|
|
Creates a new list element.
- Parameters:
-
| [in] | init | - Initialization data |
| [in] | dwUser | - User value |
| [in] | pKey | - Element key |
| [in] | dwKeySize | - Number of bytes in pKey |
- Returns:
- Pointer to new list element or NULL if error
- See also:
|
| void * CLList::NewObj |
( |
DWORD |
dwSize, |
|
|
const void * |
init = NULL, |
|
|
DWORD |
dwUser = 0, |
|
|
const void * |
pKey = NULL, |
|
|
DWORD |
dwKeySize = 0 |
|
) |
|
|
|
|
Creates and initializes a new list element without inserting.
- Parameters:
-
| [in] | dwSize | - Size of the list element |
| [in] | init | - List element initialization data |
| [in] | dwUser | - User value |
| [in] | pKey | - Key buffer |
| [in] | dwKeySize | - Number of bytes in pKey |
- Returns:
- Pointer to new list element
- See also:
|
| void* CLList::Put |
( |
LPCTSTR |
pStr |
) |
[inline] |
|
|
|
Inserts a string into the list.
- Parameters:
-
| [in] | pStr | - NULL terminated string pointer |
- Returns:
- Pointer to new list element, or NULL if error
- See also:
|
| void* CLList::Put |
( |
LPVOID |
pVal, |
|
|
DWORD |
size |
|
) |
[inline] |
|
|
|
Inserts a binary buffer value into the list.
- Parameters:
-
| [in] | pVal | - Buffer pointer |
| [in] | size | - Number of byte sin pVal |
- Returns:
- Pointer to new list element, or NULL if error
- See also:
|
| void* CLList::Put |
( |
DWORD |
dw |
) |
[inline] |
|
|
|
Inserts a DWORD value into the list.
- Parameters:
-
- Returns:
- Pointer to new list element, or NULL if error
- See also:
|
| BOOL CLList::QuickSort |
( |
BOOL |
bRecursive = TRUE |
) |
|
|
|
|
Performs a quick sort on the list.
- Parameters:
-
| [in] | bRecursive | - Set to non-zero to use the stack for sorting |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CLList::QuickSort |
( |
LPLLISTINFO * |
list, |
|
|
DWORD |
left, |
|
|
DWORD |
right |
|
) |
|
|
|
|
Provides a non-recursive quick sort.
- Parameters:
-
| [in] | list | - Pointer to list array |
| [in] | left | - Left offset into list |
| [in] | right | - Right offset into list |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CLList::Randomize |
( |
DWORD |
seed, |
|
|
DWORD |
loops = 1 |
|
) |
|
|
|
|
Randomizes the position of all list elements.
- Parameters:
-
| [in] | seed | - Random seed |
| [in] | loops | - Number of times to randomize the list |
- Returns:
- Non-zero if success
- See also:
|
| void CLList::ReleaseObject |
( |
void * |
node |
) |
|
|
|
|
Releases resources allocated for a single list element.
- Parameters:
-
| [in] | node | - Pointer to a list element |
|
| void CLList::ReleaseStr |
( |
LPSTR * |
pBuf |
) |
|
|
|
|
Releases a previously allocated string.
- Parameters:
-
| [in] | pBuf | - Pointer to string |
|
| void* CLList::ResetObject |
( |
void * |
obj, |
|
|
const void * |
init = NULL, |
|
|
DWORD |
dwUser = 0, |
|
|
const void * |
pKey = NULL, |
|
|
DWORD |
dwKeySize = 0 |
|
) |
[inline] |
|
|
|
- Parameters:
-
| [in] | obj | - Pointer to list element |
| [in] | init | - Pointer to initialization data |
| [in] | dwUser | - User value |
| [in] | pKey | - Key data |
| [in] | dwKeySize | - Number of bytes in pKey |
- Returns:
- Pointer in obj
- See also:
- SetObject()
|
| void CLList::rQuickSort |
( |
LPLLISTINFO * |
list, |
|
|
DWORD |
left, |
|
|
DWORD |
right |
|
) |
|
|
|
|
Provies a recursive quick sort.
- Parameters:
-
| [in] | list | - Pointer to list array |
| [in] | left | - Left offset into list |
| [in] | right | - Right offset into list |
|
| DWORD CLList::Save |
( |
LPCTSTR |
pFile |
) |
[virtual] |
|
|
|
Writes binary encoded list to a disk file.
- Parameters:
-
| [in] | pFile | - Disk filename |
- Returns:
- Number of bytes written to file
- See also:
Reimplemented in CParams, and CReg. |
| DWORD CLList::Save |
( |
LPBYTE |
buf, |
|
|
DWORD |
size |
|
) |
[virtual] |
|
|
|
Saves binary formated list into a memory buffer.
- Parameters:
-
| [in] | buf | - Buffer that receives binary formated list |
| [in] | size | - Size of buffer in buf |
- Returns:
- Number of bytes written to buffer
- See also:
Reimplemented in CParams. |
| const void * CLList::SetKey |
( |
void * |
ptr, |
|
|
const void * |
pKey, |
|
|
DWORD |
dwKeySize = 0 |
|
) |
[virtual] |
|
|
|
Sets a binary buffer to use as a list element key.
- Parameters:
-
| [in] | ptr | - Pointer to list element |
| [in] | pKey | - Pointer to key buffer |
| [in] | dwKeySize | - Number of bytes in pKey |
- Returns:
- Pointer to the list element in ptr
- See also:
Reimplemented in CHList. |
| void * CLList::SetObject |
( |
void * |
obj, |
|
|
const void * |
init = NULL, |
|
|
DWORD |
dwUser = 0, |
|
|
const void * |
pKey = NULL, |
|
|
DWORD |
dwKeySize = 0 |
|
) |
|
|
|
|
Sets the data inside a list element.
- Parameters:
-
| [in] | obj | - Pointer to list element |
| [in] | init | - Pointer to initialization data |
| [in] | dwUser | - User value |
| [in] | pKey | - Key data |
| [in] | dwKeySize | - Number of bytes in pKey |
- Returns:
- Pointer in obj
- See also:
- ResetObject()
|
| void CLList::SetUserData |
( |
void * |
ptr, |
|
|
DWORD |
data |
|
) |
[inline] |
|
|
|
Sets the user DWORD value into a list element.
- Parameters:
-
| [in] | ptr | - Pointer to list element |
| [in] | data | - Number of bytes in ptr. |
|
| void * CLList::VerifyPointer |
( |
void * |
ptr |
) |
[virtual] |
|
|
|
Verifys that a pointer is valid by searching for a match in the list.
- Parameters:
-
| [in] | ptr | - Pointer to a list element |
- Warning:
- This is slow since it must traverse the list until a match is found.
- Returns:
- Pointer in ptr if valid or NULL if not found
- See also:
|
| void CLList::Zero |
( |
void * |
ptr, |
|
|
DWORD |
size |
|
) |
[inline] |
|
|
|
Initializes the custom portion of a list element.
- Parameters:
-
| [in] | ptr | - List element pointer |
| [in] | size | - Size of the list element |
|
The documentation for this class was generated from the following files:
|