/*
 * 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;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
/**
 *
 * @author Rahul Semwal
 */
public class BinList 
{
    private BinNode head;
    
    public BinList()
    {
        this.head=null;
    }
    
    public BinNode getHead()
    {
        return(this.head);
    }
    
    public void addNode(LinkedHashMap<String,KMER> data,int binNumber)
    {
        
        BinNode node = new BinNode(data,binNumber);
        node.next = this.head;
        this.head=node;
    }
    
    public LinkedHashMap<String,KMER> getCurrentBin(BinNode node)
    {
        return(node.getCurrentBin());
    }
    
    public int getBinNumber(BinNode node)
    {
        return (node.getBinNumber());
    }
    
    public void reverse()
    {
        BinNode prev = null;
        BinNode current = this.head;
        @SuppressWarnings("UnusedAssignment")
        BinNode next = null;
        while (current != null) 
        {
            next = current.next;
            current.next = prev;
            prev = current;
            current = next;
        }
        this.head = prev;
    }
    
    public void deleteNode()
    {
        BinNode node;
        while(this.head!=null)
        {
            node=this.head;
            node.getCurrentBin().clear();
            this.head = this.head.next;
            node=null;   
        }
    }
}
