CLinkedList Doubly Linked List Class

Environment: VC6 SP4, All Windows platforms

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.

For those STL users reading this documentation, the obvious and proper use of classes and templates was not in the forefront of my mind when writing the examples, hence the heavy use of type casting the list return data.  For this, I offer my apologies to the more discerning user/reader.  The intent is to demonstrate functionality rather than style or other programming idioms.

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()	

Downloads

Download demo project - 35 K
Download source - 10 Kb
Download Documentation as zipped CHM - 136 K
Download Documentation as html - 630 K


Comments

  • ask

    Posted by Rabee on 10/24/2012 05:54am

    can help me with this ? write a fast program for concatenating two doubly linked list L and M,with header and trailer sentunel nodes,into a doubly linked list K (don't use loop)

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

  • Hurricane Sandy was one of the most destructive natural disasters that the United States has ever experienced. Read this success story to learn how Datto protected its partners and their customers with proactive business continuity planning, heroic employee efforts, and the right mix of technology and support. With storm surges over 12 feet, winds that exceeded 90 mph, and a diameter spanning more than 900 miles, Sandy resulted in power outages to approximately 7.5 million people, and caused an estimated $50 …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds