net.datastructures
Interface IndexList<E>

All Known Subinterfaces:
Sequence<E>
All Known Implementing Classes:
ArrayIndexList

public interface IndexList<E>

An interface for array lists.

Author:
Roberto Tamassia, Michael Goodrich

Method Summary
 void add(int i, E e)
          Inserts an element e to be at index i, shifting all elements after this.
 E get(int i)
          Returns the element at index i, without removing it.
 boolean isEmpty()
          Returns whether the list is empty.
 E remove(int i)
          Removes and returns the element at index i, shifting the elements after this.
 E set(int i, E e)
          Replaces the element at index i with e, returning the previous element at i.
 int size()
          Returns the number of elements in this list.
 

Method Detail

size

int size()
Returns the number of elements in this list.


isEmpty

boolean isEmpty()
Returns whether the list is empty.


add

void add(int i,
         E e)
         throws java.lang.IndexOutOfBoundsException
Inserts an element e to be at index i, shifting all elements after this.

Throws:
java.lang.IndexOutOfBoundsException

get

E get(int i)
      throws java.lang.IndexOutOfBoundsException
Returns the element at index i, without removing it.

Throws:
java.lang.IndexOutOfBoundsException

remove

E remove(int i)
         throws java.lang.IndexOutOfBoundsException
Removes and returns the element at index i, shifting the elements after this.

Throws:
java.lang.IndexOutOfBoundsException

set

E set(int i,
      E e)
      throws java.lang.IndexOutOfBoundsException
Replaces the element at index i with e, returning the previous element at i.

Throws:
java.lang.IndexOutOfBoundsException