uLib  User mode C/C++ extended API library for Win32 programmers.
SLinkList Class Reference

#include <uLib/ListFunc.h>

Inheritance diagram for SLinkList:
SINGLE_LIST_ENTRY

Detailed Description

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

- Protected Attributes inherited from SINGLE_LIST_ENTRY
struct _SINGLE_LIST_ENTRY * Next
 

Constructor & Destructor Documentation

◆ SLinkList()

SLinkList::SLinkList ( )
inline

Definition at line 383 of file ListFunc.h.

Member Function Documentation

◆ IsEmpty()

bool __forceinline SLinkList::IsEmpty ( )

Returns true if the list is empty.

Definition at line 508 of file ListCls.cpp.

◆ GetFirst()

PSINGLE_LIST_ENTRY SLinkList::GetFirst ( )
inline

Returns the first item in the list.

Definition at line 386 of file ListFunc.h.

◆ PushEntry()

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.

◆ PopEntry()

PSINGLE_LIST_ENTRY SLinkList::PopEntry ( )

Returns the removed entry.

Definition at line 535 of file ListCls.cpp.

◆ Append()

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.

◆ Remove()

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.

◆ operator+=()

PSINGLE_LIST_ENTRY SLinkList::operator+= ( PSINGLE_LIST_ENTRY  Entry)
inline

Prepend...

Definition at line 410 of file ListFunc.h.

◆ operator -=()

PSINGLE_LIST_ENTRY SLinkList::operator -= ( PSINGLE_LIST_ENTRY  Entry)
inline

Remove...

Definition at line 411 of file ListFunc.h.

◆ operator []()

PSINGLE_LIST_ENTRY SLinkList::operator [] ( size_t  Index)

Indexed access (can be slow)

Definition at line 595 of file ListCls.cpp.

◆ RemoveAll()

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.

◆ FirstThat()

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.

◆ ForEach()

bool SLinkList::ForEach ( PSListFunc  Action,
void *  UserData = NULL 
)

See FirstThat().

Definition at line 626 of file ListCls.cpp.

Member Data Documentation

◆ Count

UINT SLinkList::Count

Nr of items in the linked list.

Definition at line 381 of file ListFunc.h.


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