-
December 13th, 2010, 05:53 PM
#1
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...
-
December 13th, 2010, 07:37 PM
#2
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.
-
December 14th, 2010, 06:00 PM
#3
Re: singly linked list and doubly linked list
Originally Posted by Lindley
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 ???
-
December 15th, 2010, 04:09 AM
#4
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
-
December 15th, 2010, 07:31 AM
#5
Re: singly linked list and doubly linked list
what is nonitriusive linked list?
-
December 15th, 2010, 08:15 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|