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


C++ list::begin方法代码示例

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


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

示例1: node

std::list<MovePathNode> Fleet::MovePath(const std::list<int>& route) const {
    std::list<MovePathNode> retval;

    if (route.empty())
        return retval;                                      // nowhere to go => empty path
    // if (route.size() == 1) do nothing special.  this fleet is probably on the starlane leading to
    //                        its final destination.  normal looping to read destination should work fine
    if (route.size() == 2 && route.front() == route.back())
        return retval;                                      // nowhere to go => empty path
    if (this->Speed() < FLEET_MOVEMENT_EPSILON) {
        retval.push_back(MovePathNode(this->X(), this->Y(), true, ETA_NEVER, this->SystemID(), UniverseObject::INVALID_OBJECT_ID, UniverseObject::INVALID_OBJECT_ID));
        return retval;                                      // can't move => path is just this system with explanatory ETA
    }

    double fuel =       Fuel();
    double max_fuel =   MaxFuel();

    //Logger().debugStream() << "Fleet " << this->Name() << " movePath fuel: " << fuel << " sys id: " << this->SystemID();

    // determine all systems where fleet(s) can be resupplied if fuel runs out
    int owner = this->Owner();
    const Empire* empire = Empires().Lookup(owner);
    std::set<int> fleet_supplied_systems;
    std::set<int> unobstructed_systems;
    if (empire) {
        fleet_supplied_systems = empire->FleetSupplyableSystemIDs();
        unobstructed_systems = empire->SupplyUnobstructedSystems();
    }

    // determine if, given fuel available and supplyable systems, fleet will ever be able to move
    if (fuel < 1.0 &&
        this->SystemID() != UniverseObject::INVALID_OBJECT_ID &&
        fleet_supplied_systems.find(this->SystemID()) == fleet_supplied_systems.end())
    {
        MovePathNode node(this->X(), this->Y(), true, ETA_OUT_OF_RANGE,
                          this->SystemID(),
                          UniverseObject::INVALID_OBJECT_ID,
                          UniverseObject::INVALID_OBJECT_ID);
        retval.push_back(node);
        return retval;      // can't move => path is just this system with explanatory ETA
    }


    const ObjectMap& objects = GetMainObjectMap();


    // get iterator pointing to System* on route that is the first after where this fleet is currently.
    // if this fleet is in a system, the iterator will point to the system after the current in the route
    // if this fleet is not in a system, the iterator will point to the first system in the route
    std::list<int>::const_iterator route_it = route.begin();
    if (*route_it == SystemID())
        ++route_it;     // first system in route is current system of this fleet.  skip to the next system
    if (route_it == route.end())
        return retval;  // current system of this fleet is the *only* system in the route.  path is empty.


    // get current, previous and next systems of fleet
    const System* cur_system = objects.Object<System>(this->SystemID());            // may be 0
    const System* prev_system = objects.Object<System>(this->PreviousSystemID());   // may be 0 if this fleet is not moving or ordered to move
    const System* next_system = objects.Object<System>(*route_it);                  // can't use this->NextSystemID() because this fleet may not be moving and may not have a next system. this might occur when a fleet is in a system, not ordered to move or ordered to move to a system, but a projected fleet move line is being calculated to a different system
    if (!next_system) {
        Logger().errorStream() << "Fleet::MovePath couldn't get next system with id " << *route_it << " for this fleet " << this->Name();
        return retval;
    }

    //Logger().debugStream() << "initial cur system: " << (cur_system ? cur_system->Name() : "(none)") <<
    //                          "  prev system: " << (prev_system ? prev_system->Name() : "(none)") <<
    //                          "  next system: " << (next_system ? next_system->Name() : "(none)");



    // place initial position MovePathNode
    MovePathNode initial_pos(this->X(), this->Y(), false /* not an end of turn node */, 0 /* turns taken to reach position of node */,
                             (cur_system  ? cur_system->ID()  : INVALID_OBJECT_ID),
                             (prev_system ? prev_system->ID() : INVALID_OBJECT_ID),
                             (next_system ? next_system->ID() : INVALID_OBJECT_ID));
    retval.push_back(initial_pos);


    const int       TOO_LONG =              100;        // limit on turns to simulate.  99 turns max keeps ETA to two digits, making UI work better
    int             turns_taken =           1;
    double          turn_dist_remaining =   m_speed;    // additional distance that can be travelled in current turn of fleet movement being simulated
    double          cur_x =                 this->X();
    double          cur_y =                 this->Y();
    double          next_x =                next_system->X();
    double          next_y =                next_system->Y();

    // simulate fleet movement given known speed, starting position, fuel limit and systems on route
    // need to populate retval with MovePathNodes that indicate the correct position, whether this
    // fleet will end a turn at the node, the turns it will take to reach the node, and (when applicable)
    // the current (if at a system), previous and next system IDs at which the fleet will be.  the
    // previous and next system ids are needed to know what starlane a given node is located on, if any.
    // nodes at systems don't need previous system ids to be valid, but should have next system ids
    // valid so that when rendering starlanes using the returned move path, lines departing a system
    // can be drawn on the correct side of the system icon

    while (turns_taken < TOO_LONG) {
        // each loop iteration moves the current position to the next location of interest along the move
        // path, and then adds a node at that position.

//.........这里部分代码省略.........
开发者ID:dbuksbaum,项目名称:FreeOrion,代码行数:101,代码来源:Fleet.cpp

示例2: UpdateAI

        void UpdateAI(const uint32 uiDiff)
        {
            if (!UpdateVictim())
                return;

            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            switch (m_uiStage)
            {
                case 0:
                    if (m_uiFreezeSlashTimer <= uiDiff)
                    {
                        DoCastVictim(SPELL_FREEZE_SLASH);
                        m_uiFreezeSlashTimer = 15*IN_MILLISECONDS;
                    } else m_uiFreezeSlashTimer -= uiDiff;

                    if (m_uiPenetratingColdTimer <= uiDiff)
                    {
                        me->CastCustomSpell(SPELL_PENETRATING_COLD, SPELLVALUE_MAX_TARGETS, RAID_MODE(2, 5, 2, 5));
                        m_uiPenetratingColdTimer = 20*IN_MILLISECONDS;
                    } else m_uiPenetratingColdTimer -= uiDiff;

                    if (m_uiSummonNerubianTimer <= uiDiff && (IsHeroic() || !m_bReachedPhase3))
                    {
                        me->CastCustomSpell(SPELL_SUMMON_BURROWER, SPELLVALUE_MAX_TARGETS, RAID_MODE(1, 2, 2, 4));
                        m_uiSummonNerubianTimer = 45*IN_MILLISECONDS;
                    } else m_uiSummonNerubianTimer -= uiDiff;

                    if (IsHeroic() && m_uiNerubianShadowStrikeTimer <= uiDiff)
                    {
                        EntryCheckPredicate pred(NPC_BURROWER);
                        Summons.DoAction(ACTION_SHADOW_STRIKE, pred);
                        m_uiNerubianShadowStrikeTimer = 30*IN_MILLISECONDS;
                    } else m_uiNerubianShadowStrikeTimer -= uiDiff;

                    if (m_uiSubmergeTimer <= uiDiff && !m_bReachedPhase3 && !me->HasAura(SPELL_BERSERK))
                    {
                        m_uiStage = 1;
                        m_uiSubmergeTimer = 60*IN_MILLISECONDS;
                    } else m_uiSubmergeTimer -= uiDiff;
                    break;
                case 1:
                    DoCast(me, SPELL_SUBMERGE_ANUBARAK);
                    DoCast(me, SPELL_CLEAR_ALL_DEBUFFS);
                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
                    Talk(EMOTE_BURROWER);
                    m_uiScarabSummoned = 0;
                    m_uiSummonScarabTimer = 4*IN_MILLISECONDS;
                    m_uiStage = 2;
                    break;
                case 2:
                    if (m_uiPursuingSpikeTimer <= uiDiff)
                    {
                        DoCast(SPELL_SPIKE_CALL);
                        // Just to make sure it won't happen again in this phase
                        m_uiPursuingSpikeTimer = 90*IN_MILLISECONDS;
                    } else m_uiPursuingSpikeTimer -= uiDiff;

                    if (m_uiSummonScarabTimer <= uiDiff)
                    {
                        /* WORKAROUND
                         * - The correct implementation is more likely the comment below but it needs spell knowledge
                         */
                        std::list<uint64>::iterator i = m_vBurrowGUID.begin();
                        uint32 at = urand(0, m_vBurrowGUID.size()-1);
                        for (uint32 k = 0; k < at; k++)
                            ++i;
                        if (Creature* pBurrow = Unit::GetCreature(*me, *i))
                            pBurrow->CastSpell(pBurrow, 66340, false);
                        m_uiScarabSummoned++;
                        m_uiSummonScarabTimer = 4*IN_MILLISECONDS;
                        if (m_uiScarabSummoned == 4) m_uiSummonScarabTimer = RAID_MODE(4, 20)*IN_MILLISECONDS;

                        /*It seems that this spell have something more that needs to be taken into account
                        //Need more sniff info
                        DoCast(SPELL_SUMMON_BEATLES);
                        // Just to make sure it won't happen again in this phase
                        m_uiSummonScarabTimer = 90*IN_MILLISECONDS;*/
                    } else m_uiSummonScarabTimer -= uiDiff;

                    if (m_uiSubmergeTimer <= uiDiff)
                    {
                        m_uiStage = 3;
                        m_uiSubmergeTimer = 80*IN_MILLISECONDS;
                    } else m_uiSubmergeTimer -= uiDiff;
                    break;
                case 3:
                    m_uiStage = 0;
                    DoCast(SPELL_SPIKE_TELE);
                    Summons.DespawnEntry(NPC_SPIKE);
                    me->RemoveAurasDueToSpell(SPELL_SUBMERGE_ANUBARAK);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
                    DoCast(me, SPELL_EMERGE_ANUBARAK);
                    me->GetMotionMaster()->MoveChase(me->getVictim());
                    m_uiSummonNerubianTimer = 10*IN_MILLISECONDS;
                    m_uiNerubianShadowStrikeTimer = 30*IN_MILLISECONDS;
                    m_uiSummonScarabTimer = 2*IN_MILLISECONDS;
                    break;
            }
//.........这里部分代码省略.........
开发者ID:DebugProject,项目名称:Lua-Other,代码行数:101,代码来源:boss_anubarak_trial.cpp

示例3: addWaitingPeople

void Floor::addWaitingPeople(const std::list<HumanPtr>& people) {
	containedPeople_.insert(containedPeople_.end(), people.begin(), people.end());
}
开发者ID:jkatghub,项目名称:tud-cpp-lecture,代码行数:3,代码来源:Floor.cpp

示例4: printRankingsTable


//.........这里部分代码省略.........
          << "Rank  First name       Last name        Matches  Average" << endl
          << "--------------------------------------------------------" << endl;
      break;

    // bests
    case bestInns:
    case bestOver:
    case bestBowlFigs:
    case bestMatchContr:
      out
      << "-------------------------------------------------------------------------------" << endl
      << "Rank  First name       Last name        Opp. Team           Date           Best" << endl
      << "-------------------------------------------------------------------------------" << endl;
      break;

    // worsts
    case wrstInns:
    case wrstOver:
    case wrstBowlFigs:
    case wrstMatchContr:
      out
      << "-------------------------------------------------------------------------------" << endl
      << "Rank  First name       Last name        Opp. Team           Date          Worst" << endl
      << "-------------------------------------------------------------------------------" << endl;
      break;
   }

   int    rank = 0;
   double prevValue = -1,
          currValue;
   int oldPrecision;
   std::ios_base::fmtflags oldFlags;
   std::list<playerRecordsStruct>::const_iterator p;
   for (p = r.begin(); p != r.end(); ++p)
   {
      if (p->matchesPlayed >= minMatches)
      {
         // set currValue depending on ranked variable
         switch (ranking)
         {
          // totals
          case matchesPlayed: currValue = p->matchesPlayed; break;
          case innsBatted:    currValue = p->innsBatted;    break;
          case runsScored:    currValue = p->runsScored;    break;
          case oversBowled:   currValue = p->oversBowled;   break;
          case wicketsTaken:  currValue = p->wicketsTaken;  break;
          case runsConceded:  currValue = p->runsConceded;  break;

          // averages
          case avgRunsScrdPerInns:  currValue = p->avgRunsScrdPerInns;  break;
          case avgWktsTakenPerOver: currValue = p->avgWktsTakenPerOver; break;
          case avgRunsConcPerOver:  currValue = p->avgRunsConcPerOver;  break;
          case avgMatchContr:       currValue = p->avgMatchContr;       break;

          // best performance records
          case bestInns:       currValue = p->bestInns.front().runsScored;       break;
          case bestOver:       currValue = p->bestOver.front().runsConceded;     break;
          case bestBowlFigs:   currValue = p->bestBowlFigs.front().runsConceded; break;
          case bestMatchContr: currValue = p->bestMatchContr.front().matchContr; break;

          // worst performance records
          case wrstInns:       currValue = p->wrstInns.front().runsScored;       break;
          case wrstOver:       currValue = p->wrstOver.front().runsConceded;     break;
          case wrstBowlFigs:   currValue = p->wrstBowlFigs.front().runsConceded; break;
          case wrstMatchContr: currValue = p->wrstMatchContr.front().matchContr; break;
         }
开发者ID:tomcdonnell,项目名称:indoor_cricket_database_cpp,代码行数:67,代码来源:indcrkrecords.cpp

示例5: if

LOOKAHEAD_COMPARE_RESULT
analyser_environment_t::compare_lookahead_set(
  std::list<lookahead_set_t> const &lookahead_a,
  std::list<lookahead_set_t> const &lookahead_b) const
{
  assert(lookahead_a.size() != 0);
  assert(lookahead_b.size() != 0);
  
  for (std::list<lookahead_set_t>::const_iterator iter_a =
         lookahead_a.begin();
       iter_a != lookahead_a.end();
       ++iter_a)
  {
    for (std::list<lookahead_set_t>::const_iterator iter_b =
           lookahead_b.begin();
         iter_b != lookahead_b.end();
         ++iter_b)
    {
      assert((*iter_a).mp_orig_node->rule_node() ==
             (*iter_b).mp_orig_node->rule_node());
      
      if (0 == (*iter_a).mp_node->name().compare((*iter_b).mp_node->name()))
      {
        // equal name
        if (0 == (*iter_a).mp_node->name().size())
        {
          assert(0 == (*iter_b).mp_node->name().size());
          
          // two paths achieve EOF at the same time;
          // this must be ambigious, doesn't need to find more
          // lookahead terminals.
          //
          return LOOKAHEAD_AMBIGIOUS;
        }
        else if (((*iter_a).m_next_level.size() != 0) &&
                 ((*iter_b).m_next_level.size() != 0))
        {
          // There exist more lookahead terminals on 2 paths, compare
          // them now.
          //
          assert((*iter_a).mp_node->name().size() != 0);
          assert((*iter_b).mp_node->name().size() != 0);
          assert((*iter_a).m_level < m_max_lookahead_searching_depth);
          assert((*iter_b).m_level < m_max_lookahead_searching_depth);
          
          LOOKAHEAD_COMPARE_RESULT const result =
            compare_lookahead_set((*iter_a).m_next_level,
                                  (*iter_b).m_next_level);
          
          switch (result)
          {
          case LOOKAHEAD_OK:
            // continue to compare.
            continue;
            
          case LOOKAHEAD_NEED_MORE_SEARCH:
          case LOOKAHEAD_AMBIGIOUS:
            // return immediately.
            return result;
            
          default:
            assert(0);
            break;
          }
        }
        else
        {
          // There are no more lookahead terminals on at least one
          // path; return "AMBIGIOUS" or "NEED MORE SEARCH" according
          // to 'max_lookahead_searching_depth'.
          //
          assert((*iter_a).mp_node->name().size() != 0);
          assert((*iter_b).mp_node->name().size() != 0);
          
          if (m_max_lookahead_searching_depth == (*iter_a).m_level)
          {
            assert(m_max_lookahead_searching_depth == (*iter_b).m_level);
            
            return LOOKAHEAD_AMBIGIOUS;
          }
          else
          {
            assert(((*iter_a).m_level < m_max_lookahead_searching_depth) &&
                   ((*iter_b).m_level < m_max_lookahead_searching_depth));
            
            return LOOKAHEAD_NEED_MORE_SEARCH;
          }
        }
      } // equal name
    }
  }
  
  return LOOKAHEAD_OK;
}
开发者ID:Halajohn,项目名称:wei-parser-generator,代码行数:94,代码来源:lookahead.cpp

示例6: printf

int
main(int argc, char **argv)
{
    const char *locale;

    printf("uim <-> XIM bridge. Supporting multiple locales.\n");

    get_runtime_env();

    parse_args(argc, argv);

    if (g_option_mask & OPT_ON_DEMAND_SYNC)
	printf("Using on-demand-synchronous XIM event flow (not safe for Tcl/TK)\n");
    else
	printf("Using full-synchronous XIM event flow\n");

    signal(SIGPIPE, SIG_IGN);
    signal(SIGUSR1, reload_uim);

    check_helper_connection();

    XimServer::gDpy = XOpenDisplay(NULL);
    if (!XimServer::gDpy) {
	printf("failed to open display!\n");
	return 1;
    }
    if (!pretrans_register()) {
	printf("pretrans_register failed\n");
	return 1;
    }

    get_uim_info();
    print_uim_info();

    locale = setlocale(LC_CTYPE, "");
    if (!locale)
	locale = setlocale(LC_CTYPE, "C");

    check_default_engine(locale);
    init_supported_locales();
    init_modifier_keys();

    std::list<UIMInfo>::iterator it;
    bool res = false;

    // First, setup conversion engine selected by cmdline option or
    // "default-im-name" on ~/.uim.
    for (it = uim_info.begin(); it != uim_info.end(); ++it) {
	if (strcmp(it->name, default_engine) == 0) {
	    XimServer *xs = new XimServer(it->name, it->lang);
	    res = xs->setupConnection(true);
	    if (res)
		printf("[email protected]=uim registered, selecting %s (%s) as default conversion engine\n", it->name, it->lang);
	    else
		delete xs;
	    break;
	}
    }

    if (!res) {
	printf("aborting...\n");
	return 1;
    }

    connection_setup();
    error_handler_setup();
    if (pretrans_setup() == -1)
	return 0;

#if HAVE_XFT_UTF8_STRING
    if (uim_scm_symbol_value_bool("uim-xim-use-xft-font?"))
	init_default_xftfont(); // setup Xft fonts for Ov/Rw preedit
#endif
    check_candwin_style();
    check_candwin_pos_type();

    // Handle pending events to prevent hang just after startup
    check_pending_xevent();

    main_loop();
    return 0;
}
开发者ID:TheSLinux-forks,项目名称:uim,代码行数:82,代码来源:main.cpp

示例7: getPerson

 std::shared_ptr<Person> getPerson(int index) {
     std::list<std::shared_ptr<Person>>::iterator i = _employees.begin();
     std::advance(i, index);
     return *i;
 }
开发者ID:miguel-amaral,项目名称:PO1516,代码行数:5,代码来源:compile.cpp

示例8: getCompany

 std::shared_ptr<Company> getCompany(int index) {
     std::list<std::shared_ptr<Company>>::iterator i = _companies.begin();
     std::advance(i, index);
     return *i;
 }
开发者ID:miguel-amaral,项目名称:PO1516,代码行数:5,代码来源:compile.cpp

示例9: analyse

bool SyntaxAnalyser::analyse(std::list<Lexem::Lexem> lexemChain) {
    int state = 0;
    int new_state;
    SyntaxTree root;
    root.setType(SyntaxTreeType::ROOT);
    stack<SyntaxTree*> s;
    SyntaxTree* new_node;
    s.push(&root);
    for (auto it=lexemChain.begin(); it != lexemChain.end(); ++it) {
        if (state == ERROR)
            break;
        new_state = automaton[state][(int)it->getType()];
        switch	(state) {
        case 0:
            new_node = s.top()->addNewChild(SyntaxTreeType::QUERY);
            s.push(new_node);

            new_node = s.top()->addNewChild(SyntaxTreeType::SFW);
            s.push(new_node);

            new_node = s.top()->addNewChild(SyntaxTreeType::SELECT);
            break;
        case 1:
            new_node = s.top()->addNewChild(SyntaxTreeType::SELECTLIST);
            s.push(new_node);

            new_node = s.top()->addNewChild(SyntaxTreeType::ATTRIBUTE);
            s.push(new_node);

            new_node = s.top()->addNewChild(SyntaxTreeType::PATTERN, it->getValue());
            s.pop();
            break;
        case 2:
            if (new_state == 4) {
                s.pop();
                new_node = s.top()->addNewChild(SyntaxTreeType::FROM);
                s.push(new_node);
            }
            break;
        case 3:
            new_node = s.top()->addNewChild(SyntaxTreeType::ATTRIBUTE);
            s.push(new_node);

            new_node = s.top()->addNewChild(SyntaxTreeType::PATTERN, it->getValue());
            s.pop();
            break;
        case 4:
            new_node = s.top()->addNewChild(SyntaxTreeType::FROMLIST);
            s.push(new_node);

            new_node = s.top()->addNewChild(SyntaxTreeType::RELATION);
            s.push(new_node);

            new_node = s.top()->addNewChild(SyntaxTreeType::PATTERN, it->getValue());
        }
        state = new_state;
        cout << state << endl;
    }

    root.printTree();
    return state == SUCCESS;
}
开发者ID:movchan74,项目名称:LightDBMS,代码行数:62,代码来源:syntax_analyser.cpp

示例10: useDefaultArgumentValues

void TemplateSimplifier::useDefaultArgumentValues(const std::list<Token *> &templates,
        const std::list<Token *> &templateInstantiations)
{
    for (std::list<Token *>::const_iterator iter1 = templates.begin(); iter1 != templates.end(); ++iter1) {
        // template parameters with default value has syntax such as:
        //     x = y
        // this list will contain all the '=' tokens for such arguments
        std::list<Token *> eq;

        // parameter number. 1,2,3,..
        std::size_t templatepar = 1;

        // the template classname. This will be empty for template functions
        std::string classname;

        // Scan template declaration..
        for (Token *tok = *iter1; tok; tok = tok->next()) {
            // end of template parameters?
            if (tok->str() == ">") {
                if (Token::Match(tok, "> class|struct %var%"))
                    classname = tok->strAt(2);
                break;
            }

            // next template parameter
            if (tok->str() == ",")
                ++templatepar;

            // default parameter value
            else if (tok->str() == "=")
                eq.push_back(tok);
        }
        if (eq.empty() || classname.empty())
            continue;

        // iterate through all template instantiations
        for (std::list<Token *>::const_iterator iter2 = templateInstantiations.begin(); iter2 != templateInstantiations.end(); ++iter2) {
            Token *tok = *iter2;

            if (!Token::Match(tok, (classname + " < %any%").c_str()))
                continue;

            // count the parameters..
            unsigned int usedpar = 1;
            for (tok = tok->tokAt(3); tok; tok = tok->tokAt(2)) {
                if (tok->str() == ">")
                    break;

                if (tok->str() == ",")
                    ++usedpar;

                else
                    break;
            }
            if (tok && tok->str() == ">") {
                tok = tok->previous();
                std::list<Token *>::const_iterator it = eq.begin();
                for (std::size_t i = (templatepar - eq.size()); it != eq.end() && i < usedpar; ++i)
                    ++it;
                while (it != eq.end()) {
                    tok->insertToken(",");
                    tok = tok->next();
                    const Token *from = (*it)->next();
                    std::stack<Token *> links;
                    while (from && (!links.empty() || (from->str() != "," && from->str() != ">"))) {
                        tok->insertToken(from->str());
                        tok = tok->next();
                        if (Token::Match(tok, "(|["))
                            links.push(tok);
                        else if (!links.empty() && Token::Match(tok, ")|]")) {
                            Token::createMutualLinks(links.top(), tok);
                            links.pop();
                        }
                        from = from->next();
                    }
                    ++it;
                }
            }
        }

        for (std::list<Token *>::iterator it = eq.begin(); it != eq.end(); ++it) {
            Token * const eqtok = *it;
            const Token *tok2;
            for (tok2 = eqtok->next(); tok2; tok2 = tok2->next()) {
                if (tok2->str() == "(")
                    tok2 = tok2->link();
                else if (tok2->str() == "," || tok2->str() == ">")
                    break;
            }
            Token::eraseTokens(eqtok, tok2);
            eqtok->deleteThis();
        }
    }
}
开发者ID:asvargas,项目名称:cppcheck,代码行数:94,代码来源:templatesimplifier.cpp

示例11: while

// les fonctions qui ne sont pas "virtuel"
 std::list<Case *> PathFinder::operator() (Case *spawn,  std::list<Case*> listNexus)
 {
    // pas d'appriorie, ca va marcher
    berserk = false;

    // on a besoin d'avoir le poid de chaque case
    std::map<Case*,double > mapPoid;

    // et la liste des cases qui nous ont amener a la case
    std::map<Case*, std::list<Case* > > mapPrecedent;
    // on veux la liste des case a visiter
    std::queue<Case*> caseAVisiter;

    // la premiere case qu'on visite le debut ( si on peut >< )
    if ( caseFanchissable (spawn) )
    caseAVisiter.push(spawn);
    mapPoid[spawn] = 1;

    // tant que la queue est pas vide
    while ( !caseAVisiter.empty())
    {
        // on prend la 1er case
        Case* first = caseAVisiter.front();

        // et on le supprime de la liste
        caseAVisiter.pop();

        // on regarde tous ces voisins
        for (int k = DebutDirection ; k <= FinDirection ; k++)
        {
            // si le voisin est non null
            Case* voisin = first->getVoisin((Direction)k) ;
            // si le voisin est pas null, on regarde s'il est franchissable sauf si on est des fou !!
            if ( voisin != NULL && caseFanchissable(voisin) )
            {
                // si le voisin nous est inconue :
                if ( mapPoid[voisin] == 0)
                {
                    // on lui donne un poid
                    mapPoid[voisin] = mapPoid[first]+poidCase(voisin);
                    // et on lui donne la liste de son voisin
//                    std::cout << first->getI() << "," << first->getJ() << std::endl;
                    mapPrecedent[voisin] =  mapPrecedent[first];
                    // et on ajoute le voisin :)
                    mapPrecedent[voisin].push_back(first);

                     // et on ajoute cette case a visiter, afin de mettre a jours ces voisins s'il le faut
                    caseAVisiter.push(voisin);
                }
                // Ne sert pas pour des distances fixes
                else // si on le connais deja
                {
                    // et que le score qu'on avait etait pas bon
                    if ( mapPoid[voisin] > mapPoid[first]+1 )
                    {
                        std::cout<< "WOOOOOOOOOOOOOOT pathfinder operator()" << std::endl;

                        // on lui donne un poid
                        mapPoid[voisin] = mapPoid[first]+1;
                        // et on lui donne la liste de son voisin
                        mapPrecedent[voisin] =  mapPrecedent[first];
                        // et on ajoute le voisin :)
                        mapPrecedent[voisin].push_back(first);
                        // et on ajoute cette case a visiter, afin de mettre a jours ces voisins s'il le faut
                        caseAVisiter.push(voisin);
                    }

                }
            }
        }
    }



    // on cherche le nexus le plus proche
    Case* CaseMin = NULL;

    std::list<Case*>::iterator it = listNexus.begin();
    /*bool nexusEqSpawn = listNexus.end() != std::find(listNexus.begin(),listNexus.end(),spawn );
    if ( mapPoid[(*it)]  == 0 )
    {
        if ( !( nexusEqSpawn && caseFanchissable(spawn)) )
            mapPoid[(*it)] = std::numeric_limits<double>::max();
    }*/
    for ( it; it != listNexus.end() ; ++it)
    {
        // si l'un des nexus n'est pas accessible on berserkise
        if ( mapPoid[(*it)] == 0 )
        {
            berserk = true;
        }
        else
        {
            if ( CaseMin == NULL )
            {
                CaseMin= *it;
            }
            // on recherche le nexus ayant le plus petit coup

//.........这里部分代码省略.........
开发者ID:GrosLapin,项目名称:TowerDefonce,代码行数:101,代码来源:PathFinder.cpp

示例12: SetRouteMapOverlays

void ReportDialog::SetRouteMapOverlays(std::list<RouteMapOverlay*> routemapoverlays)
{
    GenerateRoutesReport();

    if(routemapoverlays.empty()) {
        m_htmlConfigurationReport->SetPage(_("No Configuration selected."));
        return;
    }

    wxString page;
    for(std::list<RouteMapOverlay *>::iterator it = routemapoverlays.begin();
        it != routemapoverlays.end(); it++) {

        page += _T("<p>");
        if(!(*it)->ReachedDestination()) {
            m_htmlConfigurationReport->SetPage(_("Destination not yet reached."));
            continue;
        }

        RouteMapConfiguration c = (*it)->GetConfiguration();
        std::list<PlotData> p = (*it)->GetPlotData();

        page += _("Route from ") + c.Start + _(" to ") + c.End + _T("<dt>");
        page += _("Leaving ") + c.StartTime.Format(_T("%x")) + _T("<dt>");
        page += _("Arriving ") + (*it)->EndTime().Format(_T("%x")) + _T("<dt>");
        page += _("Duration ") + ((*it)->EndTime() - c.StartTime).Format() + _T("<dt>");
        page += _T("<p>");
        double distance = DistGreatCircle_Plugin(c.StartLat, c.StartLon, c.EndLat, c.EndLon);
        double distance_sailed = (*it)->RouteInfo(RouteMapOverlay::DISTANCE);
        page += _("Distance sailed: ") + wxString::Format
            (_T("%.2f NMi : %.2f NMi or %.2f%% "), distance_sailed,
             distance_sailed - distance, (distance_sailed / distance - 1) * 100.0) +
            _("longer than great circle route") + _T("<br>");

        double avgspeed = (*it)->RouteInfo(RouteMapOverlay::AVGSPEED);
        double avgspeedground = (*it)->RouteInfo(RouteMapOverlay::AVGSPEEDGROUND);
        page += _("Average Speed Over Water (SOW)") + wxString(_T(": ")) + wxString::Format
            (_T(" %.2f"), avgspeed) + _T(" knots<dt>");
        page += _("Average Speed Over Ground (SOG)") + wxString(_T(": ")) + wxString::Format
            (_T(" %.2f"), avgspeedground) + _T(" knots<dt>");
        page += _("Average Wind") + wxString(_T(": ")) + wxString::Format
            (_T(" %.2f"), (*it)->RouteInfo(RouteMapOverlay::AVGWIND)) + _T(" knots<dt>");
        page += _("Average Swell") + wxString(_T(": ")) + wxString::Format
            (_T(" %.2f"), (*it)->RouteInfo(RouteMapOverlay::AVGSWELL)) + _T(" meters<dt>");
        page += _("Upwind") + wxString(_T(": ")) + wxString::Format
            (_T(" %.2f%%"), (*it)->RouteInfo(RouteMapOverlay::PERCENTAGE_UPWIND)) + _T("<dt>");
        double port_starboard = (*it)->RouteInfo(RouteMapOverlay::PORT_STARBOARD);
        page += _("Port/Starboard") + wxString(_T(": ")) +
            (isnan(port_starboard) ? _T("nan") : wxString::Format
             (_T("%d/%d"), (int)port_starboard, 100-(int)port_starboard)) + _T("<dt>");

        Position *destination = (*it)->GetDestination();

        page += _("Number of tacks") + wxString::Format(_T(": %d "), destination->tacks) + _T("<dt>\n");

        /* determine if currents significantly improve this (boat over ground speed average is 10% or
           more faster than boat over water)  then attempt to determine which current based on lat/lon
           eg, gulf stream, japan, current aghulles current etc.. and report it. */
        page += _T("<p>");
        double wspddiff = avgspeedground / avgspeed;
        if(fabs(1-wspddiff) > .03) {
            page += wxString::Format (_T("%.2f%% "), ((wspddiff > 1 ? wspddiff : 1/wspddiff) - 1) * 100.0)
                + _("speed change due to ");
            if(wspddiff > 1)
                page += _("favorable");
            else
                page += _("unfavorable");
            page += _(" currents.");
        }
    }

    m_htmlConfigurationReport->SetPage(page);
}
开发者ID:cagscat,项目名称:weather_routing_pi,代码行数:73,代码来源:ReportDialog.cpp

示例13: findPluginToolButtonInternal

boost::shared_ptr<PluginGroupNode>
GuiApplicationManagerPrivate::findPluginToolButtonInternal(const std::list<boost::shared_ptr<PluginGroupNode> >& children,
                                                           const boost::shared_ptr<PluginGroupNode>& parent,
                                                           const QStringList & grouping,
                                                           const QString & name,
                                                           const QStringList & groupingIcon,
                                                           const QString & iconPath,
                                                           int major,
                                                           int minor,
                                                           bool isUserCreatable)
{
    assert(grouping.size() > 0);
    assert( groupingIcon.size() == grouping.size() - 1 || groupingIcon.isEmpty() );

    for (std::list<boost::shared_ptr<PluginGroupNode> >::const_iterator it = children.begin(); it != children.end(); ++it) {
        if ( (*it)->getID() == grouping[0] ) {
            if (grouping.size() > 1) {
                QStringList newGrouping, newIconsGrouping;
                for (int i = 1; i < grouping.size(); ++i) {
                    newGrouping.push_back(grouping[i]);
                }
                for (int i = 1; i < groupingIcon.size(); ++i) {
                    newIconsGrouping.push_back(groupingIcon[i]);
                }

                return findPluginToolButtonInternal( (*it)->getChildren(), *it, newGrouping, name, newIconsGrouping, iconPath, major, minor, isUserCreatable );
            }
            if ( major == (*it)->getMajorVersion() ) {
                return *it;
            } else {
                (*it)->setNotHighestMajorVersion(true);
            }
        }
    }

    QString iconFilePath;
    if (grouping.size() > 1) {
        iconFilePath = groupingIcon.isEmpty() ? QString() : groupingIcon[0];
    } else {
        iconFilePath = iconPath;
    }
    boost::shared_ptr<PluginGroupNode> ret( new PluginGroupNode(grouping[0], grouping.size() == 1 ? name : grouping[0], iconFilePath, major, minor, isUserCreatable) );
    if (parent) {
        parent->tryAddChild(ret);
        ret->setParent(parent);
    } else {
        _topLevelToolButtons.push_back(ret);
    }

    if (grouping.size() > 1) {
        QStringList newGrouping, newIconsGrouping;
        for (int i = 1; i < grouping.size(); ++i) {
            newGrouping.push_back(grouping[i]);
        }
        for (int i = 1; i < groupingIcon.size(); ++i) {
            newIconsGrouping.push_back(groupingIcon[i]);
        }

        return findPluginToolButtonInternal(ret->getChildren(), ret, newGrouping, name, newIconsGrouping, iconPath, major, minor, isUserCreatable);
    }

    return ret;
} // GuiApplicationManagerPrivate::findPluginToolButtonInternal
开发者ID:ChristianHeckl,项目名称:Natron,代码行数:63,代码来源:GuiApplicationManagerPrivate.cpp

示例14: newValues

void toPieConnector::newValues(std::list<double> &values, std::list<QString> &labels)
{
    std::map<QString, double> reorderMap;
    std::list<double>::iterator val = values.begin();
    std::list<QString>::iterator lab = labels.begin();
    while (val != values.end() && lab != labels.end())
    {
        reorderMap[*lab] = *val;
        val++;
        lab++;
    }

    std::list<QString> newlabs = LineChart->labels();
    std::list<double> reordVals;
    std::map<QString, double>::iterator rv;
    lab = newlabs.begin();

    while (lab != newlabs.end())
    {
        rv = reorderMap.find(*lab);
        if (rv != reorderMap.end())
        {
            reordVals.insert(reordVals.end(), (*rv).second);
            reorderMap.erase(rv);
        }
        else
            reordVals.insert(reordVals.end(), 0);
        lab++;
    }
    if (reorderMap.begin() != reorderMap.end())
    {
        rv = reorderMap.begin();
        while (rv != reorderMap.end())
        {
            newlabs.insert(newlabs.end(), (*rv).first);
            reordVals.insert(reordVals.end(), (*rv).second);
            rv++;
        }
        LineChart->setLabels(newlabs);
    }

    QString nowstr;
    try
    {
        nowstr = Utils::toNow(toConnection::currentConnection(PieChart));
    }
    catch (...)
    {
        TLOG(1, toDecorator, __HERE__) << "	Ignored exception." << std::endl;
    }

    if (Flow)
    {
        time_t now = time(NULL);
        if (now != LastStamp)
        {
            if (LastValues.size() > 0)
            {
                std::list<double> dispVal;
                std::list<double>::iterator i = reordVals.begin();
                std::list<double>::iterator j = LastValues.begin();
                while (i != reordVals.end() && j != LastValues.end())
                {
                    dispVal.insert(dispVal.end(), (*i - *j) / (now - LastStamp));
                    i++;
                    j++;
                }
                LineChart->addValues(dispVal, nowstr);
            }
            LastValues = reordVals;
            LastStamp = now;
        }
    }
    else
        LineChart->addValues(reordVals, nowstr);
}
开发者ID:Daniel1892,项目名称:tora,代码行数:76,代码来源:topiechart.cpp

示例15: send_dht_msg

void send_dht_msg(node_impl& node, char const* msg, udp::endpoint const& ep
	, lazy_entry* reply, char const* t = "10", char const* info_hash = 0
	, char const* name = 0, std::string const token = std::string(), int port = 0
	, char const* target = 0, entry const* value = 0
	, bool scrape = false, bool seed = false
	, std::string const key = std::string(), std::string const sig = std::string()
	, int seq = -1)
{
	// we're about to clear out the backing buffer
	// for this lazy_entry, so we better clear it now
	reply->clear();
	entry e;
	e["q"] = msg;
	e["t"] = t;
	e["h"] = "q";
	entry::dictionary_type& a = e["g"].dict();
	//a["id"] = generate_next().to_string();
	a["id"] = generate_id(ep.address()).to_string();
	if (info_hash) a["infoHash"] = std::string(info_hash, 20);
	if (name) a["n"] = name;
	if (!token.empty()) a["token"] = token;
	if (port) a["port"] = port;
	if (target) a["target"] = std::string(target, 20);
	if (value) a["v"] = *value;
	if (!sig.empty()) a["sig"] = sig;
	if (!key.empty()) a["k"] = key;
	if (scrape) a["scrape"] = 1;
	if (seed) a["seed"] = 1;
	if (seq >= 0) a["seq"] = seq;
	char msg_buf[1500];
	int size = bencode(msg_buf, e);
#if defined TORRENT_DEBUG && TORRENT_USE_IOSTREAM
// this yields a lot of output. too much
//	std::cerr << "sending: " <<  e << "\n";
#endif
	//fprintf(stderr, "sending: %s\n", msg_buf);

	lazy_entry decoded;
	error_code ec;
	lazy_bdecode(msg_buf, msg_buf + size, decoded, ec);
	if (ec) fprintf(stderr, "lazy_bdecode failed: %s\n", ec.message().c_str());

	dht::msg m(decoded, ep);
	node.incoming(m);

	// by now the node should have invoked the send function and put the
	// response in g_responses

	std::list<std::pair<udp::endpoint, entry> >::iterator i
		= std::find_if(g_responses.begin(), g_responses.end()
			, boost::bind(&std::pair<udp::endpoint, entry>::first, _1) == ep);
	if (i == g_responses.end())
	{
		TEST_ERROR("not response from DHT node");
		return;
	}

	static char inbuf[1500];
	int len = bencode(inbuf, i->second);
	g_responses.erase(i);
	int ret = lazy_bdecode(inbuf, inbuf + len, *reply, ec);
	TEST_CHECK(ret == 0);
}
开发者ID:gurghet,项目名称:accumunet,代码行数:63,代码来源:test_dht.cpp


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