I would like to know how it working. Here is the question.. isnt it put the method Iterable positions();?
Please help me to figure it out.

Suppose we want to extend the PositionalList ADT with a method, indexOf(p), that returns the current index of the element stored at position p. Write this method using only other methods of the PositionalList interface (not details of our LinkedPositionalList implementation). Write the necessary code to test the method. Hint: Count the steps while traversing the list until encountering position p

public interface PositionalList<E> extends Iterable<E> {

int size();
boolean isEmpty();

Position<E> first();


Position<E> last();

Position<E> before(Position<E> p) throws IllegalArgumentException;


Position<E> after(Position<E> p) throws IllegalArgumentException;

Position<E> addFirst(E e);


Position<E> addLast(E e);


Position<E> addBefore(Position<E> p, E e)
throws IllegalArgumentException;

Inserts an element immediately after the given Position.

Position<E> addAfter(Position<E> p, E e)
throws IllegalArgumentException;


E set(Position<E> p, E e) throws IllegalArgumentException;


E remove(Position<E> p) throws IllegalArgumentException;

Iterator<E> iterator();


Iterable<Position<E>> positions();

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.