Visit the Ironworks Gaming Website Email the Webmaster Graphics Library Rules and Regulations Help Support Ironworks Forum with a Donation to Keep us Online - We rely totally on Donations from members Donation goal Meter

Ironworks Gaming Radio

Ironworks Gaming Forum

Go Back   Ironworks Gaming Forum > Ironworks Gaming Forums > General Discussion

Reply
 
Thread Tools Search this Thread
Old 03-14-2005, 08:01 AM   #1
Callum
Symbol of Cyric
 

Join Date: October 21, 2004
Location: Vancouver, BC
Age: 35
Posts: 1,143
In COmputer Science at the moment we are implementing Linked lists. Which was fine at first. Adding and deleting nodes from the head was simple enough, but now we must insert nodes in order, and delete specified nodes. THe teacher isn't giving us any help, but we are allowed to research it, so I figure asking here is fair game .

I don't have the code so far with me, as its at school only, but then, I'm asking you guys for it anyway. Any help would be much appreciated. [img]tongue.gif[/img]


Expect more questions as the week progresses, we're having a whole week of this sort of stuff
__________________
[img]\"http://img11.imageshack.us/img11/4763/callumavataranimated4ff.gif\" alt=\" - \" />
Callum is offline   Reply With Quote
Old 03-14-2005, 10:14 AM   #2
Vaskez
Takhisis Follower
 

Join Date: April 30, 2001
Location: szép Magyarország (well not right now)
Posts: 5,089
Yeah right like I'm gonna give you the code (was 4 years ago I did it anyway, prob don't have it any more) [img]tongue.gif[/img]

It's simply, just traverse the list looking at each node's pointer to "next" until you find the place you need to insert (just use a while loop). For deleting you can just go through the list again with a while loop until you find the right thing. Simple. I'll answer more specific questions properly if I can.
__________________
Too set in his ways to ever relate
If he could set that aside, there'd be heaven to pay
But weathered and aged, time swept him to grave
Love conquers all? Damn, I'd say that area's gray
Vaskez is offline   Reply With Quote
Old 03-14-2005, 06:38 PM   #3
Callum
Symbol of Cyric
 

Join Date: October 21, 2004
Location: Vancouver, BC
Age: 35
Posts: 1,143
Well, I suppose I wasn't exactly expecting the code [img]tongue.gif[/img] .

WHat you have suggested, I think I've already tried.

Here's what I have.

The ListNode class creates objects with a String variable and another ListNode object within them. The first one is called head, and so this is the only one that I actually know the name of.


To traverse the list, I created a new ListNode called positio, and set it equal to head. I then have a while loop to set position to position.getNextNode until I find what I am looking for. It is here that I encounter the problem.

If I simply do the following:

position = new ListNode(addData, position);

Then position will not be a part of the list itself, and the main list will be unchanged. Will it not?

Edit: Just noticed the word thanks doesn't appear in my post Thanks, and thanks in advance.

[ 03-14-2005, 06:41 PM: Message edited by: Callum ]
__________________
[img]\"http://img11.imageshack.us/img11/4763/callumavataranimated4ff.gif\" alt=\" - \" />
Callum is offline   Reply With Quote
Old 03-14-2005, 07:05 PM   #4
Vaskez
Takhisis Follower
 

Join Date: April 30, 2001
Location: szép Magyarország (well not right now)
Posts: 5,089
Well, why can't you do:

ListNode temp = current.NextNode;
current.NextNode = position;
position.NextNode = temp;

?

where current is the current node in the list just before the place you need to insert.

You can do a similar thing to delete.
__________________
Too set in his ways to ever relate
If he could set that aside, there'd be heaven to pay
But weathered and aged, time swept him to grave
Love conquers all? Damn, I'd say that area's gray
Vaskez is offline   Reply With Quote
Old 03-14-2005, 08:19 PM   #5
Callum
Symbol of Cyric
 

Join Date: October 21, 2004
Location: Vancouver, BC
Age: 35
Posts: 1,143
Ahha! Thank you oh wonderful one!
__________________
[img]\"http://img11.imageshack.us/img11/4763/callumavataranimated4ff.gif\" alt=\" - \" />
Callum is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
JAVA Help Needed Timber Loftis General Discussion 4 04-29-2005 04:02 PM
Java help Callum General Discussion 4 02-17-2005 09:46 AM
Window XP and JAVA help!! AngelofDeath General Conversation Archives (11/2000 - 01/2005) 2 10-31-2003 11:50 AM
Could someone help me with a Java/IE prob? Melusine General Conversation Archives (11/2000 - 01/2005) 8 04-13-2003 03:24 AM
Java help needed Memnoch General Conversation Archives (11/2000 - 01/2005) 5 05-27-2002 06:16 AM


All times are GMT -4. The time now is 07:52 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
©2024 Ironworks Gaming & ©2024 The Great Escape Studios TM - All Rights Reserved