/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package motifkmer;

/**
 *
 * @author Rahul Semwal
 * @param <T>
 */
public class LinkList<T> 
{
    private LinkNode<T> head;
    public int count;
    public LinkList()
    {
        this.head=null;
        this.count=0;
    }
    public void addNode(T data)
    {
        LinkNode<T> node = new LinkNode<>(data);
        node.next = this.head;
        this.head=node;
        this.count++;
    }
    public T getValue(LinkNode<T> node)
    {
        return(node.getValue());
    }
    public LinkNode<T> getHead()
    {
        return(this.head);
    }
    public void deleteNode()
    {
        LinkNode<T> node;
        while(this.head !=null)
        {
           node =this.head;
           this.head = this.head.next;
           node=null;        
        }
        this.count=0;
    }
    
    public  void reverse()
    {
        LinkNode<T> prev = null;
        LinkNode<T> current = this.head;
        LinkNode<T> next = null;
        while (current != null) 
        {
            next = current.next;
            current.next = prev;
            prev = current;
            current = next;
        }
        this.head = prev;
    }
}
