package Exercice5;

import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Map.Entry;

public class CuckooHashMap <K,V>{
	private ArrayList<SimpleEntry<K,V>> table1;
	private ArrayList<SimpleEntry<K,V>> table2;
	
	private static final int START_VALUE = 10;
	private static final int ENLARGE_VALUE = 10;
 	
	public CuckooHashMap() {
		table1 = new ArrayList<SimpleEntry<K,V>>(START_VALUE);
		table2 = new ArrayList<SimpleEntry<K,V>>(START_VALUE);
	}
	
	public int hash1(K cle) {
		int hash = cle.toString().hashCode();
		return hash%table1.size();
	}
	
	public int hash2(K cle) {
		int hash = cle.toString().length();
		return hash%table2.size();
	}
	
	public void put(K cle, V valeur) {
		int hash1 = hash1(cle);
		int hash2 = hash2(cle);
		
		boolean success = false;
		while(!success) {
			if(table1.get(hash1) == null) {
				table1.set(hash1, new SimpleEntry<K,V>(cle,valeur));
			}
		}
		
	}
}
