package dataBase;

import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;

import dataBase.search.DataList;

public class PictureBuffer {
	
	public static int bufferSize;
	public static int bufferTolerance;
	
	static PictureBufferElementComparator comp = new PictureBufferElementComparator();
	//DataList<PictureBufferElement> buffer;
	LinkedList<PictureBufferElement> buffer = new LinkedList<PictureBufferElement>();
	
	public PictureBuffer(){
		//buffer = new DataList<PictureBufferElement>(bufferSize, comp);
		//buffer.tolerance = bufferTolerance;
	}
	
	public synchronized BufferedImage getPicture(File f){
		
		//ArrayList<PictureBufferElement> list = buffer.dataList;
		//for(int i=0; i<list.s)
		
		Iterator<PictureBufferElement> it = buffer.iterator();
		
		while(it.hasNext()){
			
			PictureBufferElement el = it.next();
			if(el.file.equals(f)){
				it.remove();
				buffer.add(el);
				return el.image;
			}
		}
		
		for(PictureBufferElement el : list){
			if(el.equals(obj))
		}
		
		
		return null;
		
	}
	
}
