package javaCrawler;

import java.util.HashMap;
import java.util.Map;


/**
 * 
 * @author Giuseppe
 *
 *Singleton : Bill Pugh technique
 */
public class UrlToVisit{
	
	private Map<String, Record> linkToVisit = new HashMap<String, Record>();
	
	
	private UrlToVisit(){
	}


	
	private static class Instance{
		private static final UrlToVisit INSTANCE = new UrlToVisit();
	}


	public static UrlToVisit getInstance(){
		return Instance.INSTANCE;
	}

	
	public void setLinkToVisit(String key, Record value) {
		this.linkToVisit.put(key, value);
	}
	
	public   Map<String, Record> getLinkToVisit() {
		return linkToVisit;
	}
	
	
	/**
	 * read and delete the first item on the map,
	 * 
	 * @return value of the first item
	 */
	public Record next(){

		
		Map.Entry<String, Record> next = linkToVisit.entrySet().iterator().next();
		
		String key = next.getKey();
		Record value = next.getValue();
		
		linkToVisit.remove(key);
		
		return value;
	}
	
	
	public boolean containsKey(String url){

		return linkToVisit.containsKey(url);

	}

	public boolean isEmpty(){
		
		return linkToVisit.isEmpty();
		
	}
	
	
}

@@ -75,19 +75,15 @@
 %0D%0A%0D%0A
+%0D%0A
 /**
-%0D%0A * 
 %0D%0A
- 
 * @a
@@ -100,16 +100,54 @@
 eppe
+ Giorgi %3Cgiuseppe.giorgi1987@gmail.com%3E
 %0D%0A
- 
 *%0D%0A
- 
 *
+ 
 Sing
@@ -175,17 +175,16 @@
 hnique%0D%0A
- 
 */%0D%0Apubl

Update UrlToVisit.java