monthlyCalendar
Class MySortedLinkedList<T>
java.lang.Object
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 inner classes defined within the
MySortedLinkedList class. As a result they may access each other's fields even
if they are private. You are required to use the MyListNode class to implement
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 returning void (adds an element
to the list keeping the list sorted) and a remove method returning void (removes
any element(s) from the list that are equal to the parameter).
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 |
MySortedLinkedList
public MySortedLinkedList(java.util.Comparator<T> comparator)
- Creates an empty list that is associated with the specified comparator.
- Parameters:
comparator -
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