Package dsa.impl
Class SLinkedList<T>
java.lang.Object
dsa.impl.SLinkedList<T>
- All Implemented Interfaces:
IList<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfirst()
Get the first node in the list.insertAfter
(IPosition<T> n, T e) Insert elemente
into the list in the position after nodep
.insertBefore
(IPosition<T> n, T e) Insert elemente
into the list in the position before nodep
.insertFirst
(T e) Insert elemente
as the first element of the list.insertLast
(T e) Insert elemente
as the last element of the list.boolean
isEmpty()
Check if the list is empty.iterator()
Get an iterator that can iterate over the list's elements.last()
Get the last node in the list.Get the node afterp
in the list.Get the node beforep
in the list.Remove nodep
from the list.Replace the element stored in nodep
withe
.int
size()
Get the number of elements in the list.
-
Constructor Details
-
SLinkedList
public SLinkedList()
-
-
Method Details
-
size
public int size()Description copied from interface:IList
Get the number of elements in the list. -
isEmpty
public boolean isEmpty()Description copied from interface:IList
Check if the list is empty. -
first
Description copied from interface:IList
Get the first node in the list. -
last
Description copied from interface:IList
Get the last node in the list. -
next
Description copied from interface:IList
Get the node afterp
in the list. -
prev
Description copied from interface:IList
Get the node beforep
in the list. -
insertAfter
Description copied from interface:IList
Insert elemente
into the list in the position after nodep
. A new node will be created, which will havee
as its element. This node will be placed after nodep
. Ifp
was not the last node in the list, the new node will be placed betweenp
and the node after it.- Specified by:
insertAfter
in interfaceIList<T>
- Parameters:
e
-- Returns:
- The node that the new element
e
is stored in.
-
insertBefore
Description copied from interface:IList
Insert elemente
into the list in the position before nodep
. A new node will be created, which will havee
as its element. This node will be placed before nodep
. Ifp
was not the first node in the list, the new node will be placed betweenp
and the node before it.- Specified by:
insertBefore
in interfaceIList<T>
- Parameters:
e
-- Returns:
- The node that the new element
e
is stored in.
-
insertFirst
Description copied from interface:IList
Insert elemente
as the first element of the list. A new node will be created at the start of the list, which will havee
as its element. This node will be placed before any existing first node.- Specified by:
insertFirst
in interfaceIList<T>
- Parameters:
e
-- Returns:
- The node that the new element
e
is stored in.
-
insertLast
Description copied from interface:IList
Insert elemente
as the last element of the list. A new node will be created at the end of the list, which will havee
as its element. This node will be placed after any existing last node.- Specified by:
insertLast
in interfaceIList<T>
- Parameters:
e
-- Returns:
- The node that the new element
e
is stored in.
-
remove
Description copied from interface:IList
Remove nodep
from the list. -
replace
Description copied from interface:IList
Replace the element stored in nodep
withe
. This does not affect the number of elements in the list. -
iterator
Description copied from interface:IList
Get an iterator that can iterate over the list's elements.
-