Professional Documents
Culture Documents
Chapter 3
Array-based lists
An abstract class
Is superclass of the classes that implement a list
Has three instance variables
length: specifies the number of elements currently in the
list
maxSize: specifies the maximum number of elements that
can be processed by the list
list: an array of reference variables
Insert
Inserts a new item in the list
Uses method seqSearch to determine whether
insertItem is already in list
Remove
deletes an item from the list
uses the methods seqSearch and removeAt to remove
an item from the list
public Vector()
public Vector (int size)
public void addElement (Object insertObj)
public void insertElementAt (Object insertObj, int index)
public Object clone ( )
public boolean contains (Object obj)
stringList.addElement(“Spring”);
stringList.addElement(“Summer”);
stringList.addElement(“Fall”);
stringList.addElement(“Winter”);
stringList.addElement(“Cool”, 1);
Unordered List
Class UnorderedArrayList
Implementations of search, insert and remove
Time Complexity of List Operations
Vectors
Members of the class Vector
Programming examples