Remove at given node
public void remove(AnyType key)
{
if(head == null) throw new RuntimeException("cannot delete");
if( head.data.equals(key) )
{
head = head.next;
return;
}
Node<AnyType> cur = head;
Node<AnyType> prev = null;
while(cur != null && !cur.data.equals(key) )
{
prev = cur;
cur = cur.next;
}
if(cur == null) throw new RuntimeException("cannot delete");
//delete cur node
prev.next = cur.next;
}