Exemplo n.º 1
0
void treap()
{
    Treap<int> treap;

#define TREAP_LOOP   for (int i = 0; i < 1000; i ++)

	TREAP_LOOP
	{
		treap.Insert(i);
		assert(treap.GetMin() == 0);
		assert(treap.GetMax() == i);
	}

	std::cout<<"Treap constructed"<<std::endl;
	// print keys in sorted order
	treap.InOrderTraversal();

	TREAP_LOOP
	{
		assert(treap.Exists(i));
	}

	TREAP_LOOP
	{
		treap.Delete(i);
	}

	TREAP_LOOP
	{
		assert(!treap.Exists(i));
	}
}