This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes LinkedList issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "LinkedList issue" Watch "LinkedList issue" New topic
Author

LinkedList issue

Clancey Tanglefoot
Greenhorn

Joined: Feb 27, 2005
Posts: 3
I am using LinkedList's as part of java.util in an A-Star search. Is there a limit to the amount of values you can insert into a LinkedList? I thought that it expands its capacity as you insert values. Here's a example of the output:

OPEN LIST:
1 1
___________

1 1 <--Current Node
Neighbors:
1 2
2 1

OPEN LIST:
1 2
2 1
___________

1 2 <--Current Node
Neighbors:
1 3
1 1
2 2

OPEN LIST:
2 1
1 3
___________

2 1 <--Current Node
Neighbors:
2 2
3 1
1 1

OPEN LIST:
1 3
___________

1 3 <--Current Node
Neighbors:
1 4
1 2
2 3
No path found!

The neighbors should be added to the open list, but at some point are stopped being added. I can provide some code if need be. I'm just wondering if its something I'm just not aware about dealing with LinkedList. Thanks
Horatio Westock
Ranch Hand

Joined: Feb 23, 2005
Posts: 221
Hi.

The only limit on a LinkedList is memory availability.

Could you post some code for your A* implementation for us to look at?
Clancey Tanglefoot
Greenhorn

Joined: Feb 27, 2005
Posts: 3
Ok well its a bit of a mess and not really commented at all, but here is the code for the search, I can supply the aStarNode code as well:


[ February 27, 2005: Message edited by: Clancey Tanglefoot ]
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Please surround your code with [ CODE ] ... [ /CODE ] tags to keep the indentation. That's a bit of code to trudge through without indenting; can you give us an idea of where the problem lies? At least tell us which method is exhibiting the problem (produces erroneous output).

With regard to LinkedList, Horatio is correct: LinkedList is bound by memory only. Well, Collection.size() returns an int, so I suppose it's also bound by Integer.MAX_VALUE. You were thinking of ArrayList that has a capacity that is increased when it is reached, though it's still bound by the same two things as LinkedList.
Horatio Westock
Ranch Hand

Joined: Feb 23, 2005
Posts: 221
I'll try and have a look at this tomorrow, if you can wait. In the mean time, there is an here article on java A* implementations.
Clancey Tanglefoot
Greenhorn

Joined: Feb 27, 2005
Posts: 3
Ok, thanks allot for the replies. Sorry for the ugly code post, I'm new to the forums and didn't know how to best paste the code in. The article seems to be very informative, thank you. I know my issue lies in my lack of experience with java, rather than my understanding of the alogrithm. This certainly helps close the gap. Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LinkedList issue
 
Similar Threads
LinkedList
a simple problom
modificating strings
a simple but complex problom
A challenge