CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2010
    Posts
    54

    singly linked list and doubly linked list

    Hi everyone,
    I have configured singly linked list and doubly linked list but I could not understand the following concepts.Could you explain briefly with an example this concepts to me?



    1.Intrusive singly linked list
    2.Intrusive doubly linked list

    thanks in advance...

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: singly linked list and doubly linked list

    In a normal linked list, the nodes are allocated on the heap and look something like this:

    Code:
    template <typename T>
    struct Node
    {
        T data;
        Node *next;
    };
    In an intrusive list, the next pointer is assumed to be part of the T datatype, so there's no need to create a wrapper structure to store it separately. This also means there's no particular need for the nodes of the list to be on the heap; you can create a linked list of T objects "in-place", wherever the objects happen to already be, just by modifying their next pointers.

  3. #3
    Join Date
    Dec 2010
    Posts
    54

    Re: singly linked list and doubly linked list

    Quote Originally Posted by Lindley View Post
    In a normal linked list, the nodes are allocated on the heap and look something like this:

    Code:
    template <typename T>
    struct Node
    {
        T data;
        Node *next;
    };
    In an intrusive list, the next pointer is assumed to be part of the T datatype, so there's no need to create a wrapper structure to store it separately. This also means there's no particular need for the nodes of the list to be on the heap; you can create a linked list of T objects "in-place", wherever the objects happen to already be, just by modifying their next pointers.


    Code:
    template <typename T>
    struct Node
    {
        T data;
        Node *next;
    };
    this is now intrusive linked list,

    Will you give an example for nonintrusive ???

  4. #4
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: singly linked list and doubly linked list

    In an intrusive linked list, the data also plays the part of the node.

    Code:
    struct Data
    {
        // Other data members...
    
        Data *next;
    };
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  5. #5
    Join Date
    Dec 2010
    Posts
    54

    Re: singly linked list and doubly linked list

    what is nonitriusive linked list?

  6. #6
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: singly linked list and doubly linked list

    As posted above.
    The data is stored in a node, but takes no part in the linking of the list of nodes.
    Code:
    struct Node
    {
        Data data;
        Node *next;
    };
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured