monthlyCalendar
Class MySortedLinkedList<T>

java.lang.Object
  extended by monthlyCalendar.MySortedLinkedList<T>
All Implemented Interfaces:
java.lang.Iterable<T>

public class MySortedLinkedList<T>
extends java.lang.Object
implements java.lang.Iterable<T>

This class represents a simple implementation of a sorted singly-linked list. Elements added to the list are inserted in sorted order based on an specified Comparator object.

This class relies on two classes: MyIterator and MyListNode. We have implemented the MyListNode class for you but you are responsible for the implementation of the MyIterator class. Notice these are classes defined within the MySortedLinkedList class. Do not worry about that; just treat these classes as if they were defined outside of the class. Keep in mind, that you must use the MyListNode class to define the nodes of your linked list.

Feel free to add any methods to the MySortedLinkedList class you consider are necessary to implement your project. However, keep in mind that there are two methods you are required to implement: an add method (adds an element to the list keeping the list sorted) and a get method (retrieves an element based on an integer index value). The JUnit public tests provide an example of using the MySortedLinkedList class.

You may not use the Java API LinkedList or ArrayList classes during the implementation of the MySortedLinkedList class.

Author:
Dept of Computer Science, UMCP

Constructor Summary
MySortedLinkedList(java.util.Comparator<T> comparator)
          Creates an empty list that is associated with the specified comparator.
 
Method Summary
 java.util.Iterator<T> iterator()
          Returns an iterator over the elements in this list (in proper sequence).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySortedLinkedList

public MySortedLinkedList(java.util.Comparator<T> comparator)
Creates an empty list that is associated with the specified comparator.

Parameters:
comparator -
Method Detail

iterator

public java.util.Iterator<T> iterator()
Returns an iterator over the elements in this list (in proper sequence). We have implemented this method for you and you should not modify it.

Specified by:
iterator in interface java.lang.Iterable<T>
Returns:
iterator over the list


Web Accessibility