4 Replies - 1129 Views - Last Post: 24 October 2001 - 09:23 AM Rate Topic: -----

#1 EnKRYpTeD  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 128
  • Joined: 11-May 01

Looking for some help....

Posted 24 October 2001 - 08:21 AM

Hey everyone,im lookiing for some help on linked lists. Anyone know a good site, or tutorial to look at that might help me. Im really having a hard time with them here in class and this book isnt helping me much either. I understand the concept, but im not sure i understand the code or how or where to use it at.
Is This A Good Question/Topic? 0
  • +

Replies To: Looking for some help....

#2 Quik  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2
  • View blog
  • Posts: 3,750
  • Joined: 06-March 01

Re: Looking for some help....

Posted 24 October 2001 - 08:52 AM

linked lists ?
Hmm, Im not exactly sure what you mean.. Explain what you mean and I'll prolly help
Was This Post Helpful? 0
  • +
  • -

#3 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4503
  • View blog
  • Posts: 28,411
  • Joined: 21-March 01

Re: Looking for some help....

Posted 24 October 2001 - 08:56 AM

sloth didnt know quik knew C++, and yea, what he means is using structures, and nodes to make an infinite(technically) line of information, that can be added and deleted from at anytime. it uses structures and pointers.

heres some example code.

#include 

struct NODE {   NODE *pNext;   NODE *pPrev;   int nData; };

NODE *pHead, *pTail;

// Appends a node to the end of the list void AppendNode(NODE *pNode) {   if (pHead == NULL) {      pHead = pNode;      pNode->pPrev = NULL;   }   else {      pTail->pNext = pNode;      pNode->pPrev = pTail;   }   pTail = pNode;   pNode->pNext = NULL; }

// Inserts a node into the list after pAfter void InsertNode(NODE *pNode, NODE *pAfter) {   pNode->pNext = pAfter->pNext;   pNode->pPrev = pAfter;   if (pAfter->pNext != NULL)      pAfter->pNext->pPrev = pNode;   else      pTail = pNode;   pAfter->pNext = pNode; }

// Removes the specified node from the list void RemoveNode(NODE *pNode) {   if (pNode->pPrev == NULL)      pHead = pNode->pNext;   else      pNode->pPrev->pNext = pNode->pNext;   if (pNode->pNext == NULL)      pTail = pNode->pPrev;   else      pNode->pNext->pPrev = pNode->pPrev; }

// Deletes the entire list void DeleteAllNodes() {   while (pHead != NULL)      RemoveNode(pHead); }

void main() {   NODE *pNode;

  // Add items to linked list   for (int i = 0; i < 100; i++) {      pNode = new NODE;      pNode->nData = i;      AppendNode(pNode);   }   // Now display each item in list   for (pNode = pHead; pNode != NULL; pNode = pNode->pNext) {      printf("%d ", pNode->nData);   }   //   DeleteAllNodes(); }

http://gethelp.devx....n/10min0599.asp

thats where i got it from

(Edited by supersloth at 10:58 am on Oct. 24, 2001)

Was This Post Helpful? 0
  • +
  • -

#4 Quik  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2
  • View blog
  • Posts: 3,750
  • Joined: 06-March 01

Re: Looking for some help....

Posted 24 October 2001 - 09:11 AM

oh my bad.. See I just clicked the link on the main page... didnt see where it was coming from *doh*
no lol i dont know c++ :p
But im learning CGI/PERL w00t
Was This Post Helpful? 0
  • +
  • -

#5 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4503
  • View blog
  • Posts: 28,411
  • Joined: 21-March 01

Re: Looking for some help....

Posted 24 October 2001 - 09:23 AM

lol
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1