当前位置: 首页>>代码示例>>C++>>正文


C++ TList::IndexOf方法代码示例

本文整理汇总了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;
}
开发者ID:RubyBarenko,项目名称:GreenShoes---RubyLearningCourse,代码行数:58,代码来源:DCivilization.cpp


注:本文中的TList::IndexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。