net.datastructures
Class ArrayIndexList<E>

java.lang.Object
  extended by net.datastructures.ArrayIndexList<E>
All Implemented Interfaces:
IndexList<E>

public class ArrayIndexList<E>
extends java.lang.Object
implements IndexList<E>

Realization of an indexed list by means of an array, which is doubled when the size of the indexed list exceeds the capacity of the array.

Author:
Roberto Tamassia, Michael Goodrich

Constructor Summary
ArrayIndexList()
          Creates the indexed list with initial capacity 16.
 
Method Summary
 void add(int r, E e)
          Inserts an element at the given index.
 E get(int r)
          Returns the element stored at the given index.
 boolean isEmpty()
          Returns whether the indexed list is empty.
 E remove(int r)
          Removes the element stored at the given index.
 E set(int r, E e)
          Replaces the element stored at the given index.
 int size()
          Returns the number of elements in the indexed list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayIndexList

public ArrayIndexList()
Creates the indexed list with initial capacity 16.

Method Detail

size

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

Specified by:
size in interface IndexList<E>

isEmpty

public boolean isEmpty()
Returns whether the indexed list is empty.

Specified by:
isEmpty in interface IndexList<E>

get

public E get(int r)
      throws java.lang.IndexOutOfBoundsException
Returns the element stored at the given index.

Specified by:
get in interface IndexList<E>
Throws:
java.lang.IndexOutOfBoundsException

set

public E set(int r,
             E e)
      throws java.lang.IndexOutOfBoundsException
Replaces the element stored at the given index.

Specified by:
set in interface IndexList<E>
Throws:
java.lang.IndexOutOfBoundsException

add

public void add(int r,
                E e)
         throws java.lang.IndexOutOfBoundsException
Inserts an element at the given index.

Specified by:
add in interface IndexList<E>
Throws:
java.lang.IndexOutOfBoundsException

remove

public E remove(int r)
         throws java.lang.IndexOutOfBoundsException
Removes the element stored at the given index.

Specified by:
remove in interface IndexList<E>
Throws:
java.lang.IndexOutOfBoundsException