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


C++ vector::end方法代码示例

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


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

示例1: merge

void DateSpan::merge(const std::vector<DateSpan>& in, std::vector<DateSpan>* out)
{
    using DatePoints = std::map<const DateTime*, int, DateTimeCompare>;

    static const int FROM_DATE = 0x1;
    static const int TO_DATE   = 0x2;

    DatePoints date;
    for (auto in_iter = in.begin(); in_iter != in.end(); ++in_iter)
    {
        date[&((*in_iter).from_date())] |= FROM_DATE;
        date[&((*in_iter).to_date())]   |= TO_DATE;
    }

    auto date_next_iter = date.begin();
    auto date_iter = date.begin();
    for(++date_next_iter; date_next_iter != date.end(); ++date_iter, ++date_next_iter)
    {
        DateTime curr_from_date = *((*date_iter).first);
        DateTime curr_to_date = *((*date_next_iter).first);

        // 该日期不是终止日期,则去掉当前天,即日期前移1天
        if (((*date_next_iter).second & TO_DATE) == 0)
        {
            curr_to_date.addDay(1);
        }

        // 确保DatePeriod:from_date < to_date
        if (!(curr_from_date < curr_to_date))
        {
            continue;
        }

        char curr_period = 0;
        for (auto in_iter = in.begin(); in_iter != in.end(); ++in_iter)
        {
            if ((*in_iter).from_date() <= curr_from_date && curr_to_date <= (*in_iter).to_date())
            {
                curr_period |= (*in_iter).period();
            }
        }

        if (curr_period == 0)
        {
            continue;
        }

        DateSpan current(curr_from_date, curr_to_date, curr_period);
        bool need_pushed = true;
        if ((*out).size() > 0)
        {
            DateSpan& last = (*out)[(*out).size()-1];
            if (canBeMerged(last, current))
            {
                last.set_to_date(current.to_date());
                last.set_period(last.period() | current.period());
                need_pushed = false;
            }
        }
        if (need_pushed)
        {
            (*out).push_back(current);
        }
    }

    for (auto iter = (*out).begin(); iter != (*out).end(); ++iter)
    {
        (*iter).normalize();
    }
}
开发者ID:wuxuecheng,项目名称:togo,代码行数:70,代码来源:date_span.cpp

示例2: do_stuff

 void do_stuff(const std::vector<int>& v, int i) {
   std::copy(v.begin(),v.end(), std::ostream_iterator<int>(std::cout," "));
   std::cout << " i = " << i << std::endl;
 }
开发者ID:ZhuBicen,项目名称:bind_demo,代码行数:4,代码来源:bind.cpp

示例3: get_value

variant unit_callable::get_value(const std::string& key) const
{
    if(key == "x") {
        if (loc_==map_location::null_location) {
            return variant();
        } else {
            return variant(loc_.x+1);
        }
    } else if(key == "y") {
        if (loc_==map_location::null_location) {
            return variant();
        } else {
            return variant(loc_.y+1);
        }
    } else if(key == "loc") {
        if (loc_==map_location::null_location) {
            return variant();
        } else {
            return variant(new location_callable(loc_));
        }
    } else if(key == "id") {
        return variant(u_.id());
    } else if(key == "type") {
        return variant(u_.type_id());
    } else if(key == "name") {
        return variant(u_.name());
    } else if(key == "usage") {
        return variant(u_.usage());
    } else if(key == "leader") {
        return variant(u_.can_recruit());
    } else if(key == "undead") {
        return variant(u_.get_state("not_living") ? 1 : 0);
    } else if(key == "attacks") {
        const std::vector<attack_type>& att = u_.attacks();
        std::vector<variant> res;

        for( std::vector<attack_type>::const_iterator i = att.begin(); i != att.end(); ++i)
            res.push_back(variant(new attack_type_callable(*i)));
        return variant(&res);
    } else if(key == "abilities") {
        std::vector<std::string> abilities = u_.get_ability_list();
        std::vector<variant> res;

        if (abilities.empty())
            return variant( &res );

        for (std::vector<std::string>::iterator it = abilities.begin(); it != abilities.end(); ++it)
        {
            res.push_back( variant(*it) );
        }
        return variant( &res );
    } else if(key == "hitpoints") {
        return variant(u_.hitpoints());
    } else if(key == "max_hitpoints") {
        return variant(u_.max_hitpoints());
    } else if(key == "experience") {
        return variant(u_.experience());
    } else if(key == "max_experience") {
        return variant(u_.max_experience());
    } else if(key == "level") {
        return variant(u_.level());
    } else if(key == "total_movement") {
        return variant(u_.total_movement());
    } else if(key == "movement_left") {
        return variant(u_.movement_left());
    } else if(key == "attacks_left") {
        return variant(u_.attacks_left());
    } else if(key == "traits") {
        const std::vector<std::string> traits = u_.get_traits_list();
        std::vector<variant> res;

        if(traits.empty())
            return variant( &res );

        for (std::vector<std::string>::const_iterator it = traits.begin(); it != traits.end(); ++it)
        {
            res.push_back( variant(*it) );
        }
        return variant( &res );
    } else if(key == "states") {
        const std::map<std::string, std::string>& states_map = u_.get_states();

        return convert_map( states_map );
    } else if(key == "side") {
        return variant(u_.side()-1);
    } else if(key == "cost") {
        return variant(u_.cost());
    } else if(key == "vars") {
        if(u_.formula_vars()) {
            return variant(u_.formula_vars().get());
        } else {
            return variant();
        }
    } else {
        return variant();
    }
}
开发者ID:mikolson,项目名称:WesnothAddonServer,代码行数:97,代码来源:callable_objects.cpp

示例4: isShareableReference

bool StencilAnalysis::isShareableReference(const std::vector<SgExpression*> subscripts, 
					   const bool corner_yz //=FALSE
					   ) 
{
  //March 2 2011, made changes in the function, we have more robust sharing conditions
  //checks if an array reference can be replaced with shared memory reference
  //by looking at the index expressions 
  //assumes the variable is already checked for candidacy

  //check if subsrcipts are _gidx, _gidy or _gidz
  std::vector<SgExpression*>::const_iterator it;
  
  size_t count = 0;
  int indexNo = 0;

  for(it= subscripts.begin(); it != subscripts.end(); it++)
    {      
      indexNo++;
      SgExpression* index = isSgExpression(*it);

      Rose_STL_Container<SgNode*> varList = NodeQuery::querySubTree(index, V_SgVarRefExp);
      
      if(varList.size() != 1) //there should be only 1 variable and that should be gidx,y,z
	return false;
      //check if that varRef is x, y, z

      SgVarRefExp* varExp = isSgVarRefExp(*(varList.begin()));
      ROSE_ASSERT(varExp);

      string index_str = varExp->unparseToString();      
      
      if(indexNo == 1 && index_str != GIDX )
	return false;
      if(indexNo == 2 && index_str != GIDY )
	return false;
      if(indexNo == 3 && index_str != GIDZ )
	return false;

      Rose_STL_Container<SgNode*> constList = NodeQuery::querySubTree(index, V_SgIntVal);

      if(constList.size() > 1 )
	return false;

      if(constList.size() == 1)
	{

	  SgIntVal* constVal = isSgIntVal(*(constList.begin()));
	  ROSE_ASSERT(constVal);

	  if(constVal->get_value() > MAX_ORDER)
	    return false;

	  //we keep maximum 3 planes in shared memory
	  if(constVal->get_value() > 1 && indexNo == 3)
	    return false;

	  Rose_STL_Container<SgNode*> binOpList = NodeQuery::querySubTree(index, V_SgBinaryOp);
      
	  if(binOpList.size() != 1)
	    return false;

	  SgBinaryOp* binOp = isSgBinaryOp(*(binOpList.begin()));

	  //we want either one add or subtract operation in the index expression
	  //no complex indexing is supported for now. 
	  //A[i+2][i-4] is valid but A[i*2] is not valid
	  
	  if( !isSgAddOp(binOp) &&  !isSgSubtractOp(binOp))
	    return false;

	  if(indexNo == 3 && !corner_yz) 
	    { //corner of yz is only shareable when corner_yz is true
	      return false;
	    }

	}
      count++;
    }

  return (count == subscripts.size()) ? true : false ;

}
开发者ID:8l,项目名称:rose,代码行数:82,代码来源:StencilAnalysis.C

示例5: addService

bool MDNS::addService(String protocol, String service, uint16_t port, String instance, std::vector<String> subServices) {
  bool success = true;
  String status = "Ok";

  if (!labels[HOSTNAME]) {
    status = "Hostname not set";
    success = false;
  }

  if (success && protocol.length() < MAX_LABEL_SIZE - 1 && service.length() < MAX_LABEL_SIZE - 1 &&
  instance.length() < MAX_LABEL_SIZE && isAlphaDigitHyphen(protocol) && isAlphaDigitHyphen(service) && isNetUnicode(instance)) {

    PTRRecord * ptrRecord = new PTRRecord();
    SRVRecord * srvRecord = new SRVRecord();
    txtRecord = new TXTRecord();
    InstanceNSECRecord * instanceNSECRecord = new InstanceNSECRecord();

    records.push_back(ptrRecord);
    records.push_back(srvRecord);
    records.push_back(txtRecord);
    records.push_back(instanceNSECRecord);

    String serviceString = "_" + service + "._" + protocol;

    Label * protocolLabel = new Label("_" + protocol, LOCAL);

    if (labels[serviceString] == NULL) {
      labels[serviceString] = new ServiceLabel(aRecord, "_" + service, protocolLabel);
    }

    ((ServiceLabel *) labels[serviceString])->addInstance(ptrRecord, srvRecord, txtRecord);

    String instanceString = instance + "._" + service + "._" + protocol;

    labels[instanceString] = new InstanceLabel(srvRecord, txtRecord, instanceNSECRecord, aRecord, instance, labels[serviceString], true);

    for (std::vector<String>::const_iterator i = subServices.begin(); i != subServices.end(); ++i) {
      String subServiceString = "_" + *i + "._sub." + serviceString;

      if (labels[subServiceString] == NULL) {
        labels[subServiceString] = new ServiceLabel(aRecord, "_" + *i, new Label("_sub", labels[serviceString]));
      }

      PTRRecord * subPTRRecord = new PTRRecord();

      subPTRRecord->setLabel(labels[subServiceString]);
      subPTRRecord->setInstanceLabel(labels[instanceString]);

      records.push_back(subPTRRecord);

      ((ServiceLabel *) labels[subServiceString])->addInstance(subPTRRecord, srvRecord, txtRecord);
    }

    ptrRecord->setLabel(labels[serviceString]);
    ptrRecord->setInstanceLabel(labels[instanceString]);
    srvRecord->setLabel(labels[instanceString]);
    srvRecord->setPort(port);
    srvRecord->setHostLabel(labels[HOSTNAME]);
    txtRecord->setLabel(labels[instanceString]);
    instanceNSECRecord->setLabel(labels[instanceString]);
  } else {
    status = success? "Invalid name" : status;
    success = false;
  }

  return success;
}
开发者ID:glibersat,项目名称:firmware,代码行数:67,代码来源:MDNS.cpp

示例6: testRelationWrite

/** Test relation writing */
void testRelationWrite() {
    std::string left_name = "_x";
    std::string right_name = "_y";

    std::string field_left_name = "a";
    std::string field_right_name = "b";

    std::string field_left_val = "1";
    std::string field_right_val = "2";

    std::unordered_map<std::string, std::string> left_types, right_types;
    defpair e1Def, e2Def;
    valpair e1Val, e2Val;

    // setup test entity
    e1Def.push_back(std::make_pair(new IntegerColumn(), field_left_name));
    e2Def.push_back(std::make_pair(new IntegerColumn(), field_right_name));
    makeTestEntity(left_name, e1Def);
    makeTestEntity(right_name, e2Def);
    writeEntities();

    e1Val.push_back(std::make_pair(field_left_name, field_left_val));
    e2Val.push_back(std::make_pair(field_right_name, field_right_val));
    left_types.insert(std::make_pair("a", COLTYPE_NAME_INT));
    right_types.insert(std::make_pair("b", COLTYPE_NAME_INT));
    makeTestRelation(left_name, right_name, e1Val, e2Val, left_types,
        right_types);
    writeRelations();

    // Fetch the relation written
    IndexHandler ih;
    Json::Value json;
    std::string key;
    std::vector<std::string> keys;
    for (std::vector<Relation>::iterator it = openRelations.begin();
            it != openRelations.end(); ++it) {
        ih.fetchRaw(it->generateKey(), json);
        keys.push_back(it->generateKey());
        assert(std::strcmp(json[JSON_ATTR_REL_ENTL].asCString(),
            it->name_left.c_str()) == 0);
        assert(std::strcmp(json[JSON_ATTR_REL_ENTR].asCString(),
            it->name_right.c_str()) == 0);
        assert(json[JSON_ATTR_REL_FIELDSL].isMember(field_left_name));
        assert(json[JSON_ATTR_REL_FIELDSR].isMember(field_right_name));
        assert(json[JSON_ATTR_REL_FIELDSL][JSON_ATTR_FIELDS_COUNT].asInt()
            == 1);
        assert(json[JSON_ATTR_REL_FIELDSR][JSON_ATTR_FIELDS_COUNT].asInt()
            == 1);
        assert(std::strcmp(json[JSON_ATTR_REL_FIELDSL][
            std::string(JSON_ATTR_REL_TYPE_PREFIX) + field_left_name].
            asCString(), COLTYPE_NAME_INT) == 0);
        assert(std::strcmp(json[JSON_ATTR_REL_FIELDSR][
            std::string(JSON_ATTR_REL_TYPE_PREFIX) + field_right_name].
            asCString(), COLTYPE_NAME_INT) == 0);
    }

    for (defpair::iterator it = e1Def.begin() ; it != e1Def.end(); ++it)
        delete it->first;
    for (defpair::iterator it = e2Def.begin() ; it != e2Def.end(); ++it)
        delete it->first;

    // Cleanup
    removeEntities();
    removeRelations();
    releaseObjects();

    // Test Removal
    for (std::vector<std::string>::iterator it = keys.begin() ; it != keys.end(); ++it) {
        json = Json::Value();
        assert(!ih.fetchRaw(*it, json));
    }
}
开发者ID:rfaulkner,项目名称:databayes,代码行数:73,代码来源:test.cpp

示例7:

void htmlWidgetTop7Categories::getTopCategoryStats(
    std::vector<std::pair<wxString, double> > &categoryStats
    , const mmDateRange* date_range) const
{
    //Get base currency rates for all accounts
    std::map<int, double> acc_conv_rates;
    for (const auto& account: Model_Account::instance().all())
    {
        Model_Currency::Data* currency = Model_Account::currency(account);
        acc_conv_rates[account.ACCOUNTID] = currency->BASECONVRATE;
    }
    //Temporary map
    std::map<std::pair<int /*category*/, int /*sub category*/>, double> stat;

    const auto splits = Model_Splittransaction::instance().get_all();
    const auto &transactions = Model_Checking::instance().find(
            Model_Checking::TRANSDATE(date_range->start_date(), GREATER_OR_EQUAL)
            , Model_Checking::TRANSDATE(date_range->end_date(), LESS_OR_EQUAL)
            , Model_Checking::STATUS(Model_Checking::VOID_, NOT_EQUAL)
            , Model_Checking::TRANSCODE(Model_Checking::TRANSFER, NOT_EQUAL));

    for (const auto &trx : transactions)
    {
        bool withdrawal = Model_Checking::type(trx) == Model_Checking::WITHDRAWAL;
        const auto it = splits.find(trx.TRANSID);

        if (it == splits.end())
        {
            std::pair<int, int> category = std::make_pair(trx.CATEGID, trx.SUBCATEGID);
            if (withdrawal)
                stat[category] -= trx.TRANSAMOUNT * (acc_conv_rates[trx.ACCOUNTID]);
            else
                stat[category] += trx.TRANSAMOUNT * (acc_conv_rates[trx.ACCOUNTID]);
        }
        else
        {
            for (const auto& entry : it->second)
            {
                std::pair<int, int> category = std::make_pair(entry.CATEGID, entry.SUBCATEGID);
                double val = entry.SPLITTRANSAMOUNT
                    * (acc_conv_rates[trx.ACCOUNTID])
                    * (withdrawal ? -1 : 1);
                stat[category] += val;
            }
        }
    }

    categoryStats.clear();
    for (const auto& i : stat)
    {
        if (i.second < 0)
        {
            std::pair <wxString, double> stat_pair;
            stat_pair.first = Model_Category::full_name(i.first.first, i.first.second);
            stat_pair.second = i.second;
            categoryStats.push_back(stat_pair);
        }
    }

    std::stable_sort(categoryStats.begin(), categoryStats.end()
        , [] (const std::pair<wxString, double> x, const std::pair<wxString, double> y)
        { return x.second < y.second; }
    );

    int counter = 0;
    std::vector<std::pair<wxString, double> >::iterator iter;
    for (iter = categoryStats.begin(); iter != categoryStats.end(); )
    {
        counter++;
        if (counter > 7)
            iter = categoryStats.erase(iter);
        else
            ++iter;
    }
}
开发者ID:leandrosob,项目名称:moneymanagerex,代码行数:75,代码来源:mmhomepagepanel.cpp

示例8:

 ~Allocator() {
   for(typename std::vector<T*>::iterator i = chunks_.begin(); i != chunks_.end(); ++i) {
     T* chunk = *i;
     delete[] chunk;
   }
 }
开发者ID:Azzurrio,项目名称:rubinius,代码行数:6,代码来源:allocator.hpp

示例9: ActivateStoneKeepers

 void ActivateStoneKeepers()
 {
     for (std::vector<uint64>::const_iterator i = vStoneKeeper.begin(); i != vStoneKeeper.end(); ++i)
     {
         Creature *pTarget = instance->GetCreature(*i);
         if (!pTarget || !pTarget->isAlive() || pTarget->getFaction() == 14)
             continue;
         pTarget->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
         pTarget->setFaction(14);
         pTarget->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
         return;        // only want the first one we find
     }
     // if we get this far than all four are dead so open the door
     SetData (DATA_ALTAR_DOORS, DONE);
     SetDoor (uiArchaedasTempleDoor, true); //open next the door too
 }
开发者ID:ProjectStarGate,项目名称:StarGateEmu-Projekt,代码行数:16,代码来源:instance_uldaman.cpp

示例10: runPasses

/// runPasses - Run the specified passes on Program, outputting a bitcode file
/// and writing the filename into OutputFile if successful.  If the
/// optimizations fail for some reason (optimizer crashes), return true,
/// otherwise return false.  If DeleteOutput is set to true, the bitcode is
/// deleted on success, and the filename string is undefined.  This prints to
/// outs() a single line message indicating whether compilation was successful
/// or failed.
///
bool BugDriver::runPasses(Module *Program,
                          const std::vector<std::string> &Passes,
                          std::string &OutputFilename, bool DeleteOutput,
                          bool Quiet, unsigned NumExtraArgs,
                          const char * const *ExtraArgs) const {
  // setup the output file name
  outs().flush();
  SmallString<128> UniqueFilename;
  error_code EC = sys::fs::createUniqueFile(
      OutputPrefix + "-output-%%%%%%%.bc", UniqueFilename);
  if (EC) {
    errs() << getToolName() << ": Error making unique filename: "
           << EC.message() << "\n";
    return 1;
  }
  OutputFilename = UniqueFilename.str();

  // set up the input file name
  SmallString<128> InputFilename;
  int InputFD;
  EC = sys::fs::createUniqueFile(OutputPrefix + "-input-%%%%%%%.bc", InputFD,
                                 InputFilename);
  if (EC) {
    errs() << getToolName() << ": Error making unique filename: "
           << EC.message() << "\n";
    return 1;
  }

  tool_output_file InFile(InputFilename.c_str(), InputFD);

  WriteBitcodeToFile(Program, InFile.os());
  InFile.os().close();
  if (InFile.os().has_error()) {
    errs() << "Error writing bitcode file: " << InputFilename << "\n";
    InFile.os().clear_error();
    return 1;
  }

  std::string tool = OptCmd.empty()? sys::FindProgramByName("opt") : OptCmd;
  if (tool.empty()) {
    errs() << "Cannot find `opt' in PATH!\n";
    return 1;
  }

  // Ok, everything that could go wrong before running opt is done.
  InFile.keep();

  // setup the child process' arguments
  SmallVector<const char*, 8> Args;
  if (UseValgrind) {
    Args.push_back("valgrind");
    Args.push_back("--error-exitcode=1");
    Args.push_back("-q");
    Args.push_back(tool.c_str());
  } else
    Args.push_back(tool.c_str());

  Args.push_back("-o");
  Args.push_back(OutputFilename.c_str());
  for (unsigned i = 0, e = OptArgs.size(); i != e; ++i)
    Args.push_back(OptArgs[i].c_str());
  std::vector<std::string> pass_args;
  for (unsigned i = 0, e = PluginLoader::getNumPlugins(); i != e; ++i) {
    pass_args.push_back( std::string("-load"));
    pass_args.push_back( PluginLoader::getPlugin(i));
  }
  for (std::vector<std::string>::const_iterator I = Passes.begin(),
       E = Passes.end(); I != E; ++I )
    pass_args.push_back( std::string("-") + (*I) );
  for (std::vector<std::string>::const_iterator I = pass_args.begin(),
       E = pass_args.end(); I != E; ++I )
    Args.push_back(I->c_str());
  Args.push_back(InputFilename.c_str());
  for (unsigned i = 0; i < NumExtraArgs; ++i)
    Args.push_back(*ExtraArgs);
  Args.push_back(nullptr);

  DEBUG(errs() << "\nAbout to run:\t";
        for (unsigned i = 0, e = Args.size()-1; i != e; ++i)
          errs() << " " << Args[i];
        errs() << "\n";
        );
开发者ID:ADonut,项目名称:LLVM-GPGPU,代码行数:90,代码来源:OptimizerDriver.cpp

示例11: transmitPatches

void MissionControl::transmitPatches(const std::vector<katana::RoadBase::ConstPtr>& patches, u_int8_t status, u_int8_t number_of_stitches, u_int8_t patches_to_search,
                                     double matching_threshold) {

  if(status == (u_int8_t)PerceptionState::JUNCTION_AHEAD || status == (u_int8_t) PerceptionState::JUNCTION_AHEAD_AGAIN) {
    #ifdef KATANA_MC_PATCH_TRANSMIT_DEBUG
      std::cout << "MC: junction  AHEAD transmitting to lanetracker. Tranmitting patches:" << std::endl;
      for(RoadBase::ConstPtr segment : patches) {
	std::cout << "Type: " << (u_int32_t)segment->getPatchType() << segment->getAnchorPose() << std::endl;
      }
    #endif

    m_transmit_patches_func(patches, status, number_of_stitches, patches_to_search, matching_threshold);
  } else {
    // If junction is detected then insert straight patches for perception
    std::vector<katana::RoadBase::ConstPtr> working_copy;

    for(std::vector<katana::RoadBase::ConstPtr>::const_iterator it = patches.begin(); it != patches.end(); ++it) {

      // Do not insert junctions or parking patches
      if((*it)->getPatchType() >= PatchType::JUNCTION) {
	#ifdef KATANA_MC_PATCH_TRANSMIT_DEBUG
		std::cout << "MC: skipping junction or parking patch to transmit" << std::endl;
	#endif
      } else {
	// Copy patch to working copy
	working_copy.push_back(*it);
      }
    }
    m_transmit_patches_func(working_copy, status, number_of_stitches, patches_to_search , matching_threshold);
    //m_transmit_patches_func(patches, status, 0, 0, -1.0);
  }
}
开发者ID:KAtana-Karlsruhe,项目名称:AADC_2015_KAtana,代码行数:32,代码来源:mission_control.cpp

示例12: RunTests

        /// @internal
        /// @brief Determine which tests need to be run and run them
        virtual void RunTests()
        {
            if (RunAutomaticTests==RunInteractiveTests && RunInteractiveTests==false)   // enforce running automatic tests if no type of test is specified
                { RunAutomaticTests=true;  }

            if (RunAll)
            {
                for(map<String,UnitTestGroup*>::iterator Iter=TestGroups.begin(); Iter!=TestGroups.end(); ++Iter)
                    { TestGroupsToRun.push_back(Iter->first); }
            }

            if(ExecuteInThisMemorySpace) // Should we be executing the test right now?
            {
                for(std::vector<Mezzanine::String>::iterator CurrentTestName=TestGroupsToRun.begin(); CurrentTestName!=TestGroupsToRun.end(); ++CurrentTestName ) // Actually run the tests
                {
                    try{
                        TestGroups[*CurrentTestName]->RunTests(RunAutomaticTests, RunInteractiveTests);
                    } catch (std::exception e) {
                        TestError << std::endl << e.what() << std::endl;
                        // maybe we should log or somehting.
                    }

                    (*this) += *(TestGroups[*CurrentTestName]);
                }
            }else{ // No, We should be executing the test in a place that cannot possibly crash this program
                for(std::vector<Mezzanine::String>::iterator CurrentTestName=TestGroupsToRun.begin(); CurrentTestName!=TestGroupsToRun.end(); ++CurrentTestName )
                {
                    ClearTempFile();
                    if(system(String(CommandName + " " + *CurrentTestName + " " + MemSpaceArg + " " + Mezzanine::String(RunAutomaticTests?"automatic ":"") + Mezzanine::String(RunInteractiveTests?"interactive ":"")).c_str()))   // Run a single unit test as another process
                    {
                        this->AddTestResult(String("Process::" + *CurrentTestName), Testing::Failed);
                    }else {
                        this->AddTestResult(String("Process::" + *CurrentTestName), Success);
                    }

                    try
                    {
                        (*this) += GetResultsFromTempFile();
                    } catch (std::exception& e) {
                        TestError << e.what() << endl;
                    }

                }
                DeleteTempFile();
            } // \if(ExecuteInThisMemorySpace)
        } // \function
开发者ID:BlackToppStudios,项目名称:DAGFrameScheduler,代码行数:48,代码来源:mezztest.cpp

示例13: TestForExistingItem

/**
 * Function TestForExistingItem
 * test if aItem exists somewhere in lists of items
 * This is a function used by PutDataInPreviousState to be sure an item was not deleted
 * since an undo or redo.
 * This could be possible:
 *   - if a call to SaveCopyInUndoList was forgotten in Pcbnew
 *   - in zones outlines, when a change in one zone merges this zone with an other
 * This function avoids a Pcbnew crash
 * Before using this function to test existence of items,
 * it must be called with aItem = NULL to prepare the list
 * @param aPcb = board to test
 * @param aItem = item to find
 *              = NULL to build the list of existing items
 */
static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
{
    static std::vector<BOARD_ITEM*> itemsList;

    if( aItem == NULL ) // Build list
    {
        // Count items to store in itemsList:
        int icnt = 0;
        BOARD_ITEM* item;

        // Count tracks:
        for( item = aPcb->m_Track; item != NULL; item = item->Next() )
            icnt++;

        // Count modules:
        for( item = aPcb->m_Modules; item != NULL; item = item->Next() )
            icnt++;

        // Count drawings
        for( item = aPcb->m_Drawings; item != NULL; item = item->Next() )
            icnt++;

        // Count zones outlines
        icnt +=  aPcb->GetAreaCount();

        // Count zones segm (now obsolete):
        for( item = aPcb->m_Zone; item != NULL; item = item->Next() )
             icnt++;

        // Build candidate list:
        itemsList.clear();
        itemsList.reserve(icnt);

        // Store items in list:
        // Append tracks:
        for( item = aPcb->m_Track; item != NULL; item = item->Next() )
            itemsList.push_back( item );

        // Append modules:
        for( item = aPcb->m_Modules; item != NULL; item = item->Next() )
            itemsList.push_back( item );

        // Append drawings
        for( item = aPcb->m_Drawings; item != NULL; item = item->Next() )
            itemsList.push_back( item );

        // Append zones outlines
        for( int ii = 0; ii < aPcb->GetAreaCount(); ii++ )
            itemsList.push_back( aPcb->GetArea( ii ) );

        // Append zones segm:
        for( item = aPcb->m_Zone; item != NULL; item = item->Next() )
            itemsList.push_back( item );

        // Sort list
        std::sort( itemsList.begin(), itemsList.end() );
        return false;
    }

    // search in list:
    return std::binary_search( itemsList.begin(), itemsList.end(), aItem );
}
开发者ID:johnbeard,项目名称:kicad-source-mirror,代码行数:77,代码来源:board_undo_redo.cpp

示例14: removeEntities

void removeEntities() {
    RedisHandler rds(REDISDBTEST, REDISPORT);
    for (std::vector<Entity>::iterator it = openEntities.begin();
            it != openEntities.end(); ++it)
        it->remove(rds);
}
开发者ID:rfaulkner,项目名称:databayes,代码行数:6,代码来源:test.cpp

示例15: DeActivateMinions

            // used when Archaedas dies.  All active minions must be despawned.
            void DeActivateMinions()
            {
                // first despawn any aggroed wall minions
                for (std::vector<uint64>::const_iterator i = vArchaedasWallMinions.begin(); i != vArchaedasWallMinions.end(); ++i)
                {
                    Creature *pTarget = instance->GetCreature(*i);
                    if (!pTarget || pTarget->isDead() || pTarget->getFaction() != 14)
                        continue;
                    pTarget->setDeathState(JUST_DIED);
                    pTarget->RemoveCorpse();
                }

                // Vault Walkers
                for (std::vector<uint64>::const_iterator i = vVaultWalker.begin(); i != vVaultWalker.end(); ++i)
                {
                    Creature *pTarget = instance->GetCreature(*i);
                    if (!pTarget || pTarget->isDead() || pTarget->getFaction() != 14)
                        continue;
                    pTarget->setDeathState(JUST_DIED);
                    pTarget->RemoveCorpse();
                }

                // Earthen Guardians
                for (std::vector<uint64>::const_iterator i = vEarthenGuardian.begin(); i != vEarthenGuardian.end(); ++i)
                {
                    Creature *pTarget = instance->GetCreature(*i);
                    if (!pTarget || pTarget->isDead() || pTarget->getFaction() != 14)
                        continue;
                    pTarget->setDeathState(JUST_DIED);
                    pTarget->RemoveCorpse();
                }
            }
开发者ID:ProjectStarGate,项目名称:StarGateEmu-Projekt,代码行数:33,代码来源:instance_uldaman.cpp


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