Class LinkedList

java.lang.Object
  extended by LinkedList

public class LinkedList
extends java.lang.Object


Constructor Summary
LinkedList()
          Creates an empty linked list.
 
Method Summary
 boolean add(int index, Node newNode)
          Adds a node to the given index of the linked list.
 boolean delete(int index)
          Deletes a node from the given index of the linked list.
 Node getNode(int index)
          Returns the node at the given index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedList

public LinkedList()
Creates an empty linked list.

Method Detail

add

public boolean add(int index,
                   Node newNode)
Adds a node to the given index of the linked list. Returns true if successful, false otherwise.

Parameters:
index - Position at which to add the new node: 0 = head
newNode - Node to add to the linked list

delete

public boolean delete(int index)
Deletes a node from the given index of the linked list. Returns true if successful, false otherwise.

Returns:
True if delete is successful, false otherwise.

getNode

public Node getNode(int index)
Returns the node at the given index. Returns "null" if there is no node at that index.

Parameters:
index - Index of node to return
Returns:
Node at the given index (or null if it does not exist)