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


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


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

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

Top White Papers and Webcasts

  • Enterprises are increasingly looking to platform as a service (PaaS) to lower their costs and speed their time to market for new applications. Developing, deploying, and managing applications in the cloud eliminates the time and expense of managing a physical infrastructure to support them. PaaS offerings must deliver additional long-term benefits, such as a lower total cost of ownership (TCO), rapid scalability, and ease of integration, all while providing robust security and availability. This report …

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date