/*
 * Common.h
 *
 *  Created on: 2009-07-08
 *      Author: wasyl
 */

#ifndef COMMON_H_
#define COMMON_H_

#include <algorithm>
#include <allegro5/allegro.h>
#include <allegro5/a5_font.h>

/***************************************************/

#define FOREACH(ContType,ElemType,Iterator,Container) for(std::ContType<ElemType>::iterator Iterator = Container.begin(); Iterator != Container.end(); Iterator++)

/***************************************************/

template <class C, class T> void remove_element(C &container, const T &value)
{
	container.erase(std::remove(container.begin(), container.end(), value), container.end());
}

/***************************************************/

template <class C, class T, class Compare> int bs_index_worker(C &c, const T &v, int left, int right, Compare cmp)
{
/*	if (left == right)
		return -1;

	int mid = (left + right) / 2;
	T midV = c[mid];
	if (cmp(v, midV))
		return bs_index_worker()*/
	return -1;
}

template <class C, class T, class Compare> int binary_search_index(C &container, const T & value, Compare cmp)
{
	return bs_index_worker(container, value, 0, container.size(), cmp);
}

/***************************************************/

#endif /* COMMON_H_ */
