Package org.jivesoftware.util
Class LinkedList<E>
java.lang.Object
org.jivesoftware.util.LinkedList<E>
- Type Parameters:
E
- the type of linked list
Simple LinkedList implementation. The main feature is that list nodes
are public, which allows very fast delete operations when one has a
reference to the node that is to be deleted.
- Author:
- Jive Software
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds an object to the beginning of the list by automatically creating a a new node and adding it to the beginning of the list.addFirst
(LinkedListNode<E> node) Adds a node to the beginning of the list.Adds an object to the end of the list by automatically creating a a new node and adding it to the end of the list.addLast
(LinkedListNode<E> node) Adds a node to the end of the list.void
clear()
Erases all elements in the list and re-initializes it.getFirst()
Returns the first linked list node in the list.getLast()
Returns the last linked list node in the list.toString()
Returns a String representation of the linked list with a comma delimited list of all the elements in the list.
-
Constructor Details
-
LinkedList
public LinkedList()Creates a new linked list.
-
-
Method Details
-
getFirst
Returns the first linked list node in the list.- Returns:
- the first element of the list.
-
getLast
Returns the last linked list node in the list.- Returns:
- the last element of the list.
-
addFirst
Adds a node to the beginning of the list.- Parameters:
node
- the node to add to the beginning of the list.- Returns:
- the node created to wrap the object.
-
addFirst
Adds an object to the beginning of the list by automatically creating a a new node and adding it to the beginning of the list.- Parameters:
object
- the object to add to the beginning of the list.- Returns:
- the node created to wrap the object.
-
addLast
Adds a node to the end of the list.- Parameters:
node
- the node to add to the beginning of the list.- Returns:
- the node created to wrap the object.
-
addLast
Adds an object to the end of the list by automatically creating a a new node and adding it to the end of the list.- Parameters:
object
- the object to add to the end of the list.- Returns:
- the node created to wrap the object.
-
clear
public void clear()Erases all elements in the list and re-initializes it. -
toString
Returns a String representation of the linked list with a comma delimited list of all the elements in the list.
-