Need Help with Java Singly Linked List Methods

Coding a LinkedPriorityList class that implements PriorityList interf

Page 1 of 1

1 Replies - 2718 Views - Last Post: 15 February 2010 - 09:31 PM Rate Topic: -----

#1 Shabu22   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 15-February 10

Need Help with Java Singly Linked List Methods

Posted 15 February 2010 - 09:28 PM

Hello!

I'm currently coding a class called LinkedPriorityList that implements the interface PriorityList<E>. It uses a singly linked list of nodes.
The methods include:
Add at index
Remove at index
getElementAt index
lowerPriorityOf
raisePriorityOf
moveToTop
moveToLast
Object[] toArray
and so on...

I am having a lot of trouble with the Object[] toArray method that looks like this: public Object[] toArray() {
I have to return a copy of all the elements as an array of objects with the same size and order. If there are no elements in the list, I have to return new Object[0];

The other method I'm having trouble completing is the getElementAt: it looks like this: public E getElementAt(int index) {

Any help at all would be greatly appreciated!

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Need Help with Java Singly Linked List Methods

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12324
  • View blog
  • Posts: 45,424
  • Joined: 27-December 08

Re: Need Help with Java Singly Linked List Methods

Posted 15 February 2010 - 09:31 PM

You might want to check out my Linked List Tutorial. It covers the second method as well as the skills you will need to implement the first.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1