Interface ListADT<E>

All Superinterfaces:
java.lang.Iterable<E>
All Known Implementing Classes:
LinkedList

public interface ListADT<E>
extends java.lang.Iterable<E>


Method Summary
 void add(E item)
          Adds a data item to the end of the List.
 void add(int pos, E item)
          Adds a data item at position pos in the List, moving the items originally in positions pos through size() - 1 one place to the right to make room.
 boolean contains(E item)
          Returns true iff item is in the List (i.e., there is an item x in the List such that x.equals(item))
 E get(int pos)
          Returns the item at position pos in the List.
 boolean isEmpty()
          Returns true iff the List is does not have any data items.
 E remove(int pos)
          Removes and returns the item at position pos in the List, moving the items originally in positions pos+1 through size() - 1 one place to the left to fill in the gap.
 int size()
          Returns the number of items in the List.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

add

void add(E item)
Adds a data item to the end of the List.

Parameters:
item - the item to add
Throws:
java.lang.IllegalArgumentException - if item is null

add

void add(int pos,
         E item)
Adds a data item at position pos in the List, moving the items originally in positions pos through size() - 1 one place to the right to make room.

Parameters:
pos - the position at which to add the item
item - the item to add
Throws:
java.lang.IllegalArgumentException - if item is null
java.lang.IndexOutOfBoundsException - if pos is less than 0 or greater than size()

contains

boolean contains(E item)
Returns true iff item is in the List (i.e., there is an item x in the List such that x.equals(item))

Parameters:
item - the item to check
Returns:
true if item is in the List, false otherwise

get

E get(int pos)
Returns the item at position pos in the List.

Parameters:
pos - the position of the item to return
Returns:
the item at position pos
Throws:
java.lang.IndexOutOfBoundsException - if pos is less than 0 or greater than or equal to size()

isEmpty

boolean isEmpty()
Returns true iff the List is does not have any data items.

Returns:
true if the List is empty, false otherwise

remove

E remove(int pos)
Removes and returns the item at position pos in the List, moving the items originally in positions pos+1 through size() - 1 one place to the left to fill in the gap.

Parameters:
pos - the position at which to remove the item
Returns:
the item at position pos
Throws:
java.lang.IndexOutOfBoundsException - if pos is less than 0 or greater than or equal to size()

size

int size()
Returns the number of items in the List.

Returns:
the number of items in the List