|
2 registered members (Martin_HH, TipmyPip),
1,279
guests, and 10
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Linked Lists
#343957
10/12/10 10:44
10/12/10 10:44
|
Joined: Jul 2008
Posts: 170 Germany, near Mainz
Nicotin
OP
Member
|
OP
Member
Joined: Jul 2008
Posts: 170
Germany, near Mainz
|
Hello everyone,
I just read that someone already wrote a code for linked lists in Lite-C. I searched already the whole Lite-C contributions forum (where it is supposed to be) but can't find it. I only found one Thread which has a dead download link. Does someone has the code for me?
Kind regards Nico
|
|
|
Re: Linked Lists
[Re: Nicotin]
#343958
10/12/10 11:34
10/12/10 11:34
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
I don't see a sense in a code for a linked list as this can't be done by throwing a few lines of code onto a struct.
But building your own is absolutely simple, where is your problem?
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Linked Lists
[Re: Nicotin]
#343962
10/12/10 12:10
10/12/10 12:10
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
It really isn't hard. Here is a quick example:
typedef struct listNode
{
struct listNode *next;
} listNode;
listNode *firstEntry = NULL;
listNode *createNode()
{
listNode *foo = (listNode *)malloc(sizeof(listNode));
foo->next = NULL;
if(!firstEntry)
{
firstEntry = foo;
}
else
{
listNode *entry = firstEntry;
while(entry)
{
if(!entry->next)
entry->next = foo;
entry = entry->next;
}
}
return foo;
}
void removeNode(listNode *node)
{
if(firstEntry == node)
{
firstEntry = node->next;
free(node);
}
else
{
listNode *entry = firstEntry;
listNode *pentry = NULL;
while(entry)
{
if(entry == node)
{
pentry->next = entry->next;
free(node);
return;
}
pentry = entry;
entry = entry->next;
}
}
}
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Linked Lists
[Re: Nicotin]
#343964
10/12/10 12:14
10/12/10 12:14
|
Joined: Feb 2010
Posts: 320 TANA/Madagascar
3dgs_snake
Senior Member
|
Senior Member
Joined: Feb 2010
Posts: 320
TANA/Madagascar
|
Creating a linked list is not really difficult, you search for a linked list implementation in C and voilą, you have your linked list ( this is a link i found on google Linked list basic ).
|
|
|
Re: Linked Lists
[Re: Nicotin]
#343967
10/12/10 13:02
10/12/10 13:02
|
Joined: Dec 2008
Posts: 271
Saturnus
Member
|
Member
Joined: Dec 2008
Posts: 271
|
|
|
|
|
|
|