Skip to content

Instantly share code, notes, and snippets.

@samueltcsantos
Created February 5, 2015 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueltcsantos/49747014f62e093eda33 to your computer and use it in GitHub Desktop.
Save samueltcsantos/49747014f62e093eda33 to your computer and use it in GitHub Desktop.
List interface
package adt.list;
/**
* A simplified version of the java.util.List interface.
*
* @author Samuel T. C. Santos
* @version 1.0
*
*/
public interface List<E> {
/**
* Returns the number of elements in this list.
*/
public int size();
/**
* Returns whether the list is empty.
*/
public boolean isEmpty();
/**
* Returns (but does not remove) the element at index i.
*/
public E get(int i) throws IndexOutOfBoundsException;
/**
* Replaces the element at index i with e, and returns the replaced element.
*/
public E set(int i, E element) throws IndexOutOfBoundsException;
/**
* Inserts element e to be at index i, shifting all subsequent elements later.
*/
public void add(int i, E element) throws IndexOutOfBoundsException;
/**
* Removes and returns the element at index i, shifting subsequent element earlier.
*/
public E remove(int i) throws IndexOutOfBoundsException;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment