/*
 * 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 DLinkList<T> 
{
    public class DLinkNode<T>
    {
        T data;
        DLinkNode<T> next,prev;
        public DLinkNode(T data)
        {
            this.data =data;
            this.next=this.prev=null;
        }
        public T  getValue()
        {
            return this.data;
        }
    }
    private DLinkNode<T> head;
    
    public DLinkList()
    {
        this.head=null;
    }
    
    public void addNode(T data)
    {
        DLinkNode<T> node = new DLinkNode<>(data);
        if(this.head==null)
            this.head=node;
        else
        {
            node.next=this.head;
            this.head.prev=node;
            this.head=node;
        }
    }
    
    public T getValue()
    {
        return(this.head.data);
    }
    
    public DLinkNode<T> getHead()
    {
        return(this.head);
    }
    
    public void deleteNode()
    {
        DLinkNode<T> node ;
        while(this.head !=null)
        {
            node =this.head;
            this.head=this.head.next;
            node.next=node.prev=null;
            node=null;
            if(this.head!=null)
                this.head.prev=null;
        }
    }
}
