E
- the type of elements in this listpublic class MyLinkedList<E> extends java.lang.Object implements ILinkedList<E>
Modifier and Type | Class and Description |
---|---|
class |
MyLinkedList.MyLinkedListIterator |
class |
MyLinkedList.Node |
Constructor and Description |
---|
MyLinkedList() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e)
Appends the specified element to the end of this list.
|
void |
add(int index,
E e)
Inserts the specified element at the specified position in this list.
|
void |
addFirst(E e)
Adds element to head (first) of list
|
void |
addLast(E e)
Adds element to tail (last) of list
|
void |
clear()
Removes all of the elements from this list.
|
boolean |
contains(java.lang.Object o)
Returns true if this list contains the specified element.
|
E |
get(int index)
Returns the element at the specified position in this list.
|
int |
indexOf(java.lang.Object o)
Returns the index of the first occurrence of the specified element in
this list, or -1 if this list does not contain the element.
|
boolean |
isEmpty() |
int |
lastIndexOf(java.lang.Object o)
Returns the index of the last occurrence of the specified element in this list, or -1 if
this list does not contain the element.
|
MyLinkedList.MyLinkedListIterator |
listIterator()
Return a
ListIterator for the list |
E |
peek()
Peeks at element at head (first) of list
|
E |
pop()
Pops element from head (first) of list
|
void |
printDebug()
Special debug method.
|
void |
push(E e)
Pushes element onto head (first) of list
|
E |
remove(int index)
Removes the element at the specified position in this list.
|
boolean |
remove(java.lang.Object o)
Removes the first occurrence of the specified element from this list, if it is present.
|
E |
removeFirst()
Removes element from head (first) of list
|
E |
removeLast()
Removes element from tail (last) of list
|
void |
removeRange(int fromIndex,
int toIndex)
Removes from this list all of the elements whose index is between fromIndex,
inclusive, and toIndex, exclusive.
|
E |
set(int index,
E e) |
int |
size() |
public void printDebug()
public boolean add(E e)
IList
public void add(int index, E e)
IList
public boolean remove(java.lang.Object o)
IList
public E remove(int index)
IList
public void removeRange(int fromIndex, int toIndex)
IList
(toIndex - fromIndex)
elements.
(If toIndex==fromIndex
, this operation has no effect.)removeRange
in interface IList<E>
fromIndex
- index of first element to be removedtoIndex
- index after last element to be removedpublic E get(int index)
IList
public boolean contains(java.lang.Object o)
IList
(o==null ? e==null : o.equals(e))
.public int indexOf(java.lang.Object o)
IList
(o==null ? get(i)==null : o.equals(get(i)))
, or -1
if there is no such index.public int lastIndexOf(java.lang.Object o)
IList
(o==null ? get(i)==null : o.equals(get(i)))
, or -1
if there is no such index.lastIndexOf
in interface IList<E>
o
- element to search forpublic void clear()
IList
public int size()
public boolean isEmpty()
public void addFirst(E e)
ILinkedList
addFirst
in interface ILinkedList<E>
e
- the new elementpublic void addLast(E e)
ILinkedList
addLast
in interface ILinkedList<E>
e
- the new elementpublic E removeFirst()
ILinkedList
removeFirst
in interface ILinkedList<E>
public E removeLast()
ILinkedList
removeLast
in interface ILinkedList<E>
public void push(E e)
ILinkedList
push
in interface ILinkedList<E>
e
- the new elementpublic E pop()
ILinkedList
pop
in interface ILinkedList<E>
public E peek()
ILinkedList
peek
in interface ILinkedList<E>
public MyLinkedList.MyLinkedListIterator listIterator()
ILinkedList
ListIterator
for the listlistIterator
in interface ILinkedList<E>
ListIterator
for the list