Class LinkedList
java.lang.Object
|
+--LinkedList
- public class LinkedList
- extends java.lang.Object
A singly-linked collection class of Nodes. Allows a Node to be
inserted at the beginning of the list, the end of the list, or in
order as long as the Node data is Object. Can also determine if
an element is in the list, as well as whether it is empty, or the
number of elements in the list
You must write a method that will filter the list based on a
Comparable passed as a parameter.
Constructor Summary |
LinkedList()
default constructor, initializes to an empty list |
Method Summary |
boolean |
isEmpty()
does the list have any values? |
void |
prepend(java.lang.Comparable obj)
inserts the obj at the beginning of the list |
java.lang.String |
toString()
Returns all the elements of this list as a String |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
LinkedList
public LinkedList()
- default constructor, initializes to an empty list
isEmpty
public boolean isEmpty()
- does the list have any values?
- Returns:
- true if list is empty, false otherwise
prepend
public void prepend(java.lang.Comparable obj)
- inserts the obj at the beginning of the list
- Parameters:
the
- object to be inserted
toString
public java.lang.String toString()
- Returns all the elements of this list as a String
- Overrides:
toString
in class java.lang.Object
- Returns:
- list of elements