Ejemplo n.º 1
0
void TestArraySorting2(void)
{
	CArrayInt	cInts;

	cInts.Init();
	cInts.Add(4);
	cInts.Add(3);
	cInts.Add(2);
	cInts.Add(1);

	cInts.QuickSort();

	AssertInt(1, cInts.GetValue(0));
	AssertInt(2, cInts.GetValue(1));
	AssertInt(3, cInts.GetValue(2));
	AssertInt(4, cInts.GetValue(3));

	cInts.Kill();

	cInts.Init();
	cInts.Add(4);
	cInts.Add(3);
	cInts.Add(2);
	cInts.Add(1);

	cInts.BubbleSort();

	AssertInt(1, cInts.GetValue(0));
	AssertInt(2, cInts.GetValue(1));
	AssertInt(3, cInts.GetValue(2));
	AssertInt(4, cInts.GetValue(3));

	cInts.Kill();
}
int CInputDeviceDesc::GetUnusedID(void)
{
	int				i;
	CInputDevice*	pcDevice;
	CArrayInt		aiIDs;
	int				iID;

	if (mapcDevices.NumElements() == 0)
	{
		return 0;
	}
	else if (mapcDevices.NumElements() == 1)
	{
		pcDevice = *mapcDevices.Get(0);
		if (pcDevice->GetDescriptionID() == 0)
		{
			return 1;
		}
		return 0;
	}

	aiIDs.Init();
	for (i = 0; i < mapcDevices.NumElements(); i++)
	{
		pcDevice = *mapcDevices.Get(i);
		aiIDs.Add(pcDevice->GetDescriptionID());
	}
	aiIDs.QuickSort();
	iID = aiIDs.FindUnusedInSorted();
	aiIDs.Kill();
	return iID;
}