Created
February 5, 2015 04:08
-
-
Save samueltcsantos/49747014f62e093eda33 to your computer and use it in GitHub Desktop.
List interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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