Steven Stalone

Greenhorn
+ Follow
since Dec 07, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steven Stalone

Hello Everyone,

I have to implement an Ordered List using a Linked List, using the following class definitions:

class linkedlist {
int indexOf(Object o) {}
void add(Object o) {}
void addFirst(Object o) {}
void addLast(Object o) {}
void addAtIndex(int index, Object o) {}
Object get(int index) {}
Iterator getIterator() {}
}

class orderedlist {
Comparator comparator;
OrderedList(Comparator c) {
this.comparator = c;
}
int indexOf(Object o);
Object get(int index);
void add(Object o);
Iterator getIterator();
}

I am not asking for you to provide me with the solution, however I was wondering if anyone had any idea what I am supposed to use the getIterator() method for? I am implementing this once using composition, and a second time using inheritance. I am guessing that I have to use an Iterator when adding an item to the List - I will iterate through the list and use a Comparator to compare each item, and then perform the ordered insertion. What is actually supposed to happen in the getIterator() method? Why must there be this method in both OrderedList and LinkedList?

Any help would be appreciated, thanks...
12 years ago