It seems that over time, all programmers, engineers and other code authors have come to terms with and fully understand some of the abstract data types that come with the territory of C/C++ coding. Many prefer to use their own abstract data types, while others use some of the existing algorithms provided by the STL or elsewhere. My own list routines evolved over time and I think that they are at least worthy of submitting to the CodeGuru as I believe this particular set of Doubly Linked List routines should provide most full-blown functionality that any coder would ever need.
This source code began its early days in the "C" language before the advent of C++ ( yes, this indicates how old I am) and subsequently the STL and its associated Container classes, templates, algorithms, etc. As such, the CLinkedList class is extremely stable and if you believe that the STL is suitable, please continue to do so by all means. However, if you're looking for that extra speed that you think could make a difference in your final product, then the CLinkedList class is definitely worthwhile having a look at, because there are virtually no processing overheads when compared to the number of corresponding or appropriate STL function calls.
The source code is fully commented and there is also a Compiled Help File included with many examples. I have also included the html files for those people who prefer to use a different browser, however, Microsoft's Internet explorer 4 and above is recommended.
Below is a list of the CLinkedList class member functions, Happy Coding!
CLinkedList Member Functions:
Returns Prototype Description NULL Constructor(...) The constructor for the class. int dladd( LPVOID data ) Add ( insert ) a node into the list int dladdins( LPVOID data ) Add a node to the list with an insertion sort. int dlatmark( void ) Test to see if at a previously marked node in the list. LPVOID dlbsearch( LPVOID data ) Perform a binary search of the list. LONG dlcount( void) Return the number of nodes in the list. int dldelete( void ) Delete the current node. LPVOID dlfind( LPVOID data ) Find a node in the list with this data. LPVOID dlget( void ) Get currency, a "fresh" copy of the data in the current node. LPVOID dlgoback( void ) Travel backwards through the list to the previous node. LPVOID dlgofwd( void ) Travel forwards through the list to the next node. int dlinsert( LPVOID data ) Insert a node into the list at this point. int dlmark( void ) Mark (tag) a particular node in the list. LONG dlposn( void ) Return the nodes position in the list. int dlqsort( void ) Sort the list using the qsort library function. int dlreplace( LPVOID data ) Replace the current node with this data. int dlrewind( void ) Rewind to the start of the list. int dlsetcompare( pfunction ) Change the user supplied comparison function to another. int dlsort( void ) Sort the list using a primitive swap sort algorithm. BOOL dlsorted( void ) Flag indicating whether the list is sorted or not. LPVOID dltofirst( void ) Go to the first node in the list. LPVOID dltolast( void ) Go to the last node in the list. int dltomark( void ) Go to a previously marked node in the list. int dlunmark( void ) Unmark a previously marked node. int DumpMemory( ) Dump the contents of some memory to the debug screen. int dldumplist( void ) Dump the contents of the entire list to the debug screen. int dldumpnode( void ) Dump the contents of a single node to the debug screen. int operator<<( LPVOID ) The same as dladd() LPVOID operator( LONG ) Array access operator LPVOID operator++( int ) Equates to dlgofwd() LPVOID operator--( int ) Equates to dlgoback()
DownloadsDownload demo project - 35 K
Download source - 10 Kb
Download Documentation as zipped CHM - 136 K
Download Documentation as html - 630 K