本文整理汇总了C++中TList::IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::IndexOf方法的具体用法?C++ TList::IndexOf怎么用?C++ TList::IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::IndexOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindMainRoads
//---------------------------------------------------------------------------
// Description: Highlights the routes with the heigher pheromone intesity
// starting from the Nest. If the Food source is not reached
// after a given number of tries, stop the search and draw the
// result.
bool __fastcall Civilization::FindMainRoads(int Ntries, TImage *ImageBox, const int RWidth, const float Scale)
{
// Start from the Anthill...
City *CurrentCity = Nest;
TList *MainRoads = new TList();
while(CurrentCity!=FoodSourceCity && Ntries>0)
{
int PheroLevel = -MAXINT;
Route *CurrentRoad = NULL;
City* NextCity;
Route* thisRoad;
// the following loop select the best road acording to the pheromone level
for(int j=0; j<Roads->Count; j++)
{
thisRoad = (Route*)Roads->Items[j];
// if the road has a conection with the current city...
NextCity = thisRoad->GetConection(CurrentCity);
// Test the highest Pheromone level among the possible roads...
// if 'thisRoad' was not used before...
if(NextCity!=NULL && MainRoads->IndexOf(thisRoad)==-1)
{
if(thisRoad->GetPheromone() > PheroLevel)
{
CurrentRoad = thisRoad;
PheroLevel = thisRoad->GetPheromone();
}
}
}
// Go to next city using the selected road...
if(CurrentCity!=NULL && CurrentRoad!=NULL)
{
CurrentCity = CurrentRoad->GetConection(CurrentCity);
MainRoads->Add(CurrentRoad);
}
Ntries--;
}
// Draw the MainRoad
Rebuild(ImageBox,Scale);
// Draw all the roads
for(int i=0; i<MainRoads->Count; i++)
{
ImageBox->Canvas->Pen->Width = RWidth;
((Route*)MainRoads->Items[i])->DrawRoad(ImageBox,clRed,Scale);
ImageBox->Canvas->Pen->Width = 1;
}
return (Ntries>0)?true:false;
}