472,954 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

generic linked list

How do I implement a generic linked list?
Feb 26 '08 #1
4 5064

<se**************@yahoo.co.inwrote in message
news:83**********************************@x30g2000 hsd.googlegroups.com...
How do I implement a generic linked list?
typedef struct node
{
struct node *prev;
struct node *next;
void *data;
} NODE;

typedef struct
{
struct node *first;
struct node *last;
} LINKEDLIST;
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Feb 26 '08 #2
se**************@yahoo.co.in wrote:
How do I implement a generic linked list?
What do you mean by "generic?"

--
Er*********@sun.com
Feb 26 '08 #3
se**************@yahoo.co.in wrote:
How do I implement a generic linked list?
Depends.
The usual way is to have a struct containing
the list infrastructure and a pointer to the data
and provide ways for the user to affect the data,
e.g. via function pointers.

With
struct GenSLList {
struct GenSLList *pNext;
void *pData;
};
you can perform some operations purely on the linked list,
like inserting new nodes
struct GenSLList *pNode1, *pNode2;
....
pNode1->pNext = pNode2;
whereas things like creating new nodes, deleting nodes, sorting
the list etc. need your input:
struct GenSLList*
CreateSllNode (int (*CreateDataFrom)(void**, void*),
void *pTemplateData);
which provides a new list node and, depending on the CreateDataFrom
and pTemplateData parameters, may do things to also provide
new data or set the pData member to pTemplateData or ...

Note that general programming / algorithm / data structure questions
may be better asked in comp.programming. As soon as you have written
some C code and have specific questions regarding that code, you can
ask here.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Feb 26 '08 #4
<se**************@yahoo.co.inwrote in message
news:83**********************************@x30g2000 hsd.googlegroups.com...
How do I implement a generic linked list?
Use the list.h set of interfaces from the linux kernerl sources
Feb 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Stig Brautaset | last post by:
Hi group, I'm playing with a little generic linked list/stack library, and have a little problem with the interface of the pop() function. If I used a struct like this it would be simple: ...
6
by: Nick Valeontis | last post by:
I know how to use Icomparable. However, I can't figure out how to sort a generic linked list? (without writing the algorithm) Lets say I have something like this: class...
10
by: Egghead | last post by:
Hi all, Can someone kindly enough point me to some situations that we shall or "must" use Generic Class? I can foresee the Generic Method is powerful, but I can not find a single situation that...
7
by: =?Utf-8?B?Sm9lbCBNZXJr?= | last post by:
I have created a custom class with both value type members and reference type members. I then have another custom class which inherits from a generic list of my first class. This custom listneeds...
3
by: swetha bandaru | last post by:
what is meant by generic linked list.How to implement it in c? can anyone plz help me.
0
by: Atos | last post by:
SINGLE-LINKED LIST Let's start with the simplest kind of linked list : the single-linked list which only has one link per node. That node except from the data it contains, which might be...
11
by: Scott Stark | last post by:
Hello, The code below represents a singly-linked list that accepts any type of object. You can see I'm represting the Data variable a System.Object. How would I update this code to use...
4
by: Tony Johansson | last post by:
Hello! What actually does this sentence mean? Create a linked-list generic class that enables you to create a chain of different objects types. When I create a linked-list generic class for...
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.