Wednesday, September 22, 2010

The List interface

A List is an ordered Collection (sometimes called a sequence).(Sets are unordered collections)
Unlike sets, Lists may contain duplicate elements. In addition to the operations inherited from Collection, the List interface includes operations for:
  • Positional Access: manipulate elements based on their numerical position in the list.
  • Search: search for a specified object in the list and return its numerical position.
  • List Iteration: extend Iterator semantics to take advantage of the list's sequential nature.
  • Range-view: perform arbitrary range operations on the list.

The List interface is shown below:

public interface List extends Collection {
// Positional Access
Object get(int index);
Object set(int index, Object element);
// Optional
void add(int index, Object element);
// Optional
Object remove(int index);
// Optional
abstract boolean addAll(int index, Collection c);
// Optional // Search
int indexOf(Object o);
int lastIndexOf(Object o);
// Iteration
ListIterator listIterator();
ListIterator listIterator(int index);
// Range-view
List subList(int from, int to);

Comparing List to Vector

ListIterator Interface

List Implementations in java

Operations on Lists

Generic Lists in Java

Performance of List implementations in java

No comments:

Post a Comment