Interface ListInterface<I>


public interface ListInterface<I>

This interface indicates the public methods that need to be implemented for Homework 3 of CMP-338, Fall 2015.

Author:
Sameh Fakhouri

Method Summary
 void add(I obj)
          This method is called to add the specified object to the end of the list.
 boolean add(I obj, int index)
          This method is called to add the specified object to the list at the given index.
 void addSorted(I obj)
          This method is called to add the specified object to the list in sorted order.
 I getFirstObject()
          This method is called to obtain the first object in the list.
 I getNextObject()
          This method is called to obtain the next object in the list.
 I getObject(int index)
          This method is called to retrieve the object at the specified index.
 boolean isEmpty()
          This method is called to determine if the list is empty.
 boolean remove(int index)
          This method is called to remove the object at the specified index
 void removeAll()
          This method removes all objects from the list, making the list empty.
 int size()
          This method is called to obtain the count of elements in the list.
 

Method Detail

isEmpty

boolean isEmpty()
This method is called to determine if the list is empty.

Returns:
Returns true if the list is empty, otherwise it returns false.

size

int size()
This method is called to obtain the count of elements in the list.

Returns:
Returns the numbers of Objects that are currently in the list.

add

void add(I obj)
This method is called to add the specified object to the end of the list.

Parameters:
obj - A reference to the object to be added to the end of the list. All objects being added to the list must implement the Comparable interface.
See Also:
Comparable

add

boolean add(I obj,
            int index)
This method is called to add the specified object to the list at the given index.

Parameters:
obj - A reference to the object to be added to the list. All objects being added to the list must implement the Comparable interface.
index - Indicates the position at which to add the specified object. Using and index = 0, indicates that the object being added should become the head of the list and should succeed even if the list is currently empty.
Returns:
Returns true if the object was successfully added at the given index. If the given index is invalid, this method returns false, indicating that the specified object was not added to the list.
See Also:
Comparable

addSorted

void addSorted(I obj)
This method is called to add the specified object to the list in sorted order. More specifically, the objects preceding the specified object must be "less than" the specified object, and the objects following the specified object must be "greater that or equal to" the specified object.

Parameters:
obj - A reference to the Object being added, in sorted order, to the list. All objects being added to the list must implement the Comparable interface.
See Also:
Comparable

getObject

I getObject(int index)
This method is called to retrieve the object at the specified index.

Parameters:
index - Indicates the position from which to retrieve the object.
Returns:
Returns a reference to the Object at the given index, or nullL if the given index is invalid.

getFirstObject

I getFirstObject()
This method is called to obtain the first object in the list. Calling this method initializes an internal private variable to allow stepping through the list.

Returns:
Returns a reference to the first Object in the list, or null if the list is empty.
See Also:
getNextObject()

getNextObject

I getNextObject()
This method is called to obtain the next object in the list. This method should not be called, unless getFirstObject() has been called. When this method returns null it automatically ends the stepping through the list.

Returns:
Returns a reference to the next Object in the list. Or, null if there are no more objects in the list. This method also returns null if getFirstObject() was not called.
See Also:
getFirstObject()

remove

boolean remove(int index)
This method is called to remove the object at the specified index

Parameters:
index - Indicates the position from which to remove the object.
Returns:
Returns true if the object was successfully removed from the given index, or false if the given index is invalid.

removeAll

void removeAll()
This method removes all objects from the list, making the list empty.