uLib
User mode C/C++ extended API library for Win32 programmers.
|
#include <uLib/ListFunc.h>
Single linked null terminated list manipulation class.
SLinkList is essentially a stack (LIFO), with some added features.
The protected SINGLE_LIST_ENTRY is the list head.
Note: There exist two flavors of single linked lists, null terminated and semicircular.
Null terminated lists initialize the list head to NULL, and semicircular lists initialize
the list head to point to itself. SLinkList implements the former, in compliance with DDK.
Definition at line 379 of file ListFunc.h.
Public Data | |
UINT | Count |
Public Functions | |
SLinkList () | |
bool __forceinline | IsEmpty () |
PSINGLE_LIST_ENTRY | GetFirst () |
PSINGLE_LIST_ENTRY | PushEntry (PSINGLE_LIST_ENTRY Entry) |
PSINGLE_LIST_ENTRY | PopEntry () |
PSINGLE_LIST_ENTRY | Append (PSINGLE_LIST_ENTRY Entry) |
PSINGLE_LIST_ENTRY | Remove (PSINGLE_LIST_ENTRY Entry) |
PSINGLE_LIST_ENTRY | operator+= (PSINGLE_LIST_ENTRY Entry) |
PSINGLE_LIST_ENTRY | operator -= (PSINGLE_LIST_ENTRY Entry) |
PSINGLE_LIST_ENTRY | operator [] (size_t Index) |
void | RemoveAll (PSListFunc ItemAction, void *UserData=NULL) |
PSINGLE_LIST_ENTRY | FirstThat (PSListFunc Match, void *UserData=NULL) |
bool | ForEach (PSListFunc Action, void *UserData=NULL) |
Additional Inherited Members | |
![]() | |
struct _SINGLE_LIST_ENTRY * | Next |
|
inline |
Definition at line 383 of file ListFunc.h.
bool __forceinline SLinkList::IsEmpty | ( | ) |
Returns true if the list is empty.
Definition at line 508 of file ListCls.cpp.
|
inline |
Returns the first item in the list.
Definition at line 386 of file ListFunc.h.
PSINGLE_LIST_ENTRY SLinkList::PushEntry | ( | PSINGLE_LIST_ENTRY | Entry | ) |
Push/Pop is the regular single linked list feature.
That is, Push makes Entry the first item, and Pop removes the same.
Returns the added entry.
Definition at line 520 of file ListCls.cpp.
PSINGLE_LIST_ENTRY SLinkList::PopEntry | ( | ) |
Returns the removed entry.
Definition at line 535 of file ListCls.cpp.
PSINGLE_LIST_ENTRY SLinkList::Append | ( | PSINGLE_LIST_ENTRY | Entry | ) |
[ Preliminary ] Append inserts Entry as the last item in the single link list.
This is done by traversing the list until the last entry, and inserting
the Entry following that, which is not particularly quick if the list has
a significant length, but sometimes you may need a queue, not a stack.
The normal operation of a single link list is to prepend new entries.
Definition at line 556 of file ListCls.cpp.
PSINGLE_LIST_ENTRY SLinkList::Remove | ( | PSINGLE_LIST_ENTRY | Entry | ) |
[ Preliminary ]
Remove an entry from anywhere in the list. Return Entry if found, else NULL.
Definition at line 577 of file ListCls.cpp.
|
inline |
Prepend...
Definition at line 410 of file ListFunc.h.
|
inline |
Remove...
Definition at line 411 of file ListFunc.h.
PSINGLE_LIST_ENTRY SLinkList::operator [] | ( | size_t | Index | ) |
Indexed access (can be slow)
Definition at line 595 of file ListCls.cpp.
void SLinkList::RemoveAll | ( | PSListFunc | ItemAction, |
void * | UserData = NULL |
||
) |
RemoveAll cleans up the list..
It removes entries one by one and calls ItemAction on each.
Use the ItemAction callback to delete/dispose your entries.
Definition at line 603 of file ListCls.cpp.
PSINGLE_LIST_ENTRY SLinkList::FirstThat | ( | PSListFunc | Match, |
void * | UserData = NULL |
||
) |
Item enumeration.
Note: These iterators are not intended for cleaning up your list, use RemoveAll() for that.
If you must delete an entry in the callback function, be sure to use PopEntry() or Remove(), otherwise Count will get skewed.
Definition at line 611 of file ListCls.cpp.
bool SLinkList::ForEach | ( | PSListFunc | Action, |
void * | UserData = NULL |
||
) |
See FirstThat().
Definition at line 626 of file ListCls.cpp.
UINT SLinkList::Count |
Nr of items in the linked list.
Definition at line 381 of file ListFunc.h.