// input: two trees waiting to be compared, the resultpointer) repository
// output: the updated resultpointer) repository (it's a hashing table with "long int: int" pair in)
void IBD_hash(char * tree1, char * tree2, unordered_map<long int, double> * resultpointer)
{
	// NOTE:
	// in practice, we can store the second hashing table, and when next time we enter, we can directly use it
	// we can achieve this by storing the second hashing table as global in this scope

	(*resultpointer).clear();

	// clean the global variables
	h11.clear();
	list1.clear();
	list3.clear();
	rubbish.clear();

	parser1(tree1);

	// DEBUG
	/*
	for(auto itr = h11[124.8].begin(); itr != h11[124.8].end(); itr ++)
	{
		cout << (*itr)->tMRCA << ":" << (*itr)->start << " " << (*itr)->middle << " " << (*itr)->end << " " << endl;
	}
	*/


	parser2(tree2, resultpointer);

	// empty the temporary rubbish pool
	for(auto itr = rubbish.begin(); itr != rubbish.end(); itr ++)
	{
		free(*itr);
	}

	// free the h11 memory for fear that there will be memory overflow
	for(auto itr = h11.begin(); itr != h11.end(); itr ++)
	{
		// (*itr) is a forward_list<MRCA *>
		for(auto itr1 = (*itr).second.begin(); itr1 != (*itr).second.end(); itr1 ++)
		{
			// (*itr1) is a (MRCA *)
			free(*itr1);
		}
	}
	return;
}