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


C++ Station::getName方法代码示例

本文整理汇总了C++中Station::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Station::getName方法的具体用法?C++ Station::getName怎么用?C++ Station::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Station的用法示例。


在下文中一共展示了Station::getName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: findRoute

void Dijstra::findRoute(Station start, Station end){
  graph costs;
  std::priority_queue<pp, std::vector<pp>, Prioritize> queue;

  // all the stations have int_max as cost
  for(graph::iterator it=g.begin(); it!=g.end(); it++) {
    costs[it->first][it->first] = INT_MAX;

    for(distance::iterator jt=it->second.begin(); jt!=it->second.end(); ++jt){
      costs[jt->first][jt->first] = INT_MAX;
    }
  }

  // set first station to cost 0
  costs[start][start] = 0;
  queue.push(pp(start, 0));
  while(!queue.empty()) {
    // get the station with the lowest cost
    Station station = queue.top().first;
    queue.pop();

    for(graph::iterator it=costs.begin(); it!=costs.end(); ++it) {
      int cost = costs[it->first].begin()->second;

      // go through all stations and get edge cost
      if(g[station].find(it->first) != g[station].end())
        cost = g[station][it->first];
      else if(g[it->first].find(station) != g[it->first].end())
        cost = g[it->first][station];

      // check for a cheaper option
      if (costs[it->first].begin()->second > costs[station].begin()->second + cost) {

        Station old = costs[it->first].begin()->first;
        costs[it->first].erase(old);

        costs[it->first][station] = costs[station].begin()->second + cost;
        queue.push(pp(it->first, costs[it->first].begin()->second));
      }
    }
  }

  std::cout<<"cost "<<costs[end].begin()->second<<"\n";
  std::cout<<"station "<<end.getName()<<"\n";

  Station station = costs[end].begin()->first;

  while(costs[station].begin()->second != 0){
    std::cout<<"station "<<station.getName()<<"\n";
    station = costs[station].begin()->first;
  }

  std::cout<<"station "<<start.getName()<<"\n";
};
开发者ID:Gneroso,项目名称:university_projects,代码行数:54,代码来源:dijstra.cpp

示例2: rMain

int
station_get_name(LuaState* state)
{
  Station* station = rMain()->getMission()->getStation();
  wstring stationName = station->getName();
  state->PushWString(stationName.c_str());
  return 1;
}
开发者ID:MrPhil,项目名称:ShortHike,代码行数:8,代码来源:ScriptStation.cpp

示例3: testParseFile

void TestConfig::testParseFile()
{
    //QCOMPARE(10.0, filter.getValue());

    ConfigParse config("files/config01.xml");
    QList<Station> *list;
    list = new QList<Station>;

    config.parse(list);

    QCOMPARE(config.getMosqServer(), QString("localhost"));
    QCOMPARE(config.getAppName(),    QString("FunTechHouse_METAR2MQTT2__01"));

    QCOMPARE(list->size(), 1);


    {
        Station station = list->at(0);
        QCOMPARE(station.getName(),      QString("EKCH"));
        QCOMPARE(station.getMosqTopic(), QString("METAR/EKCH"));
    }

}
开发者ID:darcyg,项目名称:METAR2MQTT,代码行数:23,代码来源:TestConfig.cpp


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