List ADT


Conceptual picture

 

 

 

 

 

Operations

List ADT as a Java interface

Using the List ADT

Given a ListADT named myList, write a code fragment to reverse myList without using another ListADT (extra challenge: do it without using an array).

 

 

 

 

 

 

 

 

 

 

Implementing the ListADT using an array

public class SimpleArrayList implements ListADT<Object> {
 
    private Object[] items; // the items in the List
    private int numItems;   // the number of items in the List
 
    public SimpleArrayList() { ... }      
 
  //*** required ListADT methods ***
 
    public void add(Object item) { ... }  
    public void add(int pos, Object item) { ... }   
    public Object remove(int pos) { ... }  
    public Object get (int pos) { ... }  
    public boolean contains (Object item) { ... }
    public int size() { ... }      
    public boolean isEmpty() { ... }  
    
    
    
}