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


C++ set::count方法代码示例

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


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

示例1: visitSetGlobal

 void visitSetGlobal(SetGlobal* curr) {
   if (reachable.count(ModuleElement(ModuleElementKind::Global, curr->name)) == 0) {
     queue.emplace_back(ModuleElementKind::Global, curr->name);
   }
 }
开发者ID:aheejin,项目名称:binaryen,代码行数:5,代码来源:RemoveUnusedModuleElements.cpp

示例2: WasWrapped

 bool WasWrapped(uint64 guid)
 {
     return lWrappedPlayers.count(guid);
 }
开发者ID:Carbinfibre,项目名称:Script-Land,代码行数:4,代码来源:boss_slad_ran.cpp

示例3: contains

	bool contains(EdgeId e) const {
		return edges_.count(e) > 0;
	}
开发者ID:fw1121,项目名称:Pandoras-Toolbox-for-Bioinformatics,代码行数:3,代码来源:graph_component.hpp

示例4: find

 inline bool find( unsigned int hash ) { return images.count( hash ) > 0; }
开发者ID:mdl8bit,项目名称:caesaria-game,代码行数:1,代码来源:picture_bank.cpp

示例5: compileLispFragment

static int compileLispFragment(char const*& d, char const* e, bool _quiet, bytes& o_code, vector<unsigned>& o_locs, map<string, unsigned>& _vars)
{
	std::map<std::string, Instruction> const c_arith = { { "+", Instruction::ADD }, { "-", Instruction::SUB }, { "*", Instruction::MUL }, { "/", Instruction::DIV }, { "%", Instruction::MOD } };
	std::map<std::string, pair<Instruction, bool>> const c_binary = { { "<", { Instruction::LT, false } }, { "<=", { Instruction::GT, true } }, { ">", { Instruction::GT, false } }, { ">=", { Instruction::LT, true } }, { "=", { Instruction::EQ, false } }, { "!=", { Instruction::EQ, true } } };
	std::map<std::string, Instruction> const c_unary = { { "!", Instruction::NOT } };
	std::set<char> const c_allowed = { '+', '-', '*', '/', '%', '<', '>', '=', '!' };

	bool exec = false;
	int outs = 0;
	bool seq = false;

	while (d != e)
	{
		// skip to next token
		for (; d != e && !isalnum(*d) && *d != '(' && *d != ')' && *d != '{' && *d != '}' && *d != '_' && *d != '"' && *d != '@' && *d != '[' && !c_allowed.count(*d) && *d != ';'; ++d) {}
		if (d == e)
			break;

		switch (*d)
		{
		case ';':
			for (; d != e && *d != '\n'; ++d) {}
			break;
		case '(':
			exec = true;
			++d;
			break;
		case '{':
			++d;
			while (d != e)
			{
				bytes codes;
				vector<unsigned> locs;
				outs = 0;
				int o;
				if ((o = compileLispFragment(d, e, _quiet, codes, locs, _vars)) > -1)
				{
					for (int i = 0; i < outs; ++i)
						o_code.push_back((byte)Instruction::POP);	// pop additional items off stack for the previous item (final item's returns get left on).
					outs = o;
					appendCode(o_code, o_locs, codes, locs);
				}
				else
					break;
			}
			seq = true;
			break;
		case '}':
			if (seq)
			{
				++d;
				return outs;
			}
			return -1;
		case ')':
			if (exec)
			{
				++d;
				return outs;
			}
			else
				// unexpected - return false as we don't know what to do with it.
				return -1;

		case '@':
		{
			if (exec)
				return -1;
			bool store = false;
			++d;
			if (*d == '@')
			{
				++d;
				store = true;
			}
			bytes codes;
			vector<unsigned> locs;
			if (compileLispFragment(d, e, _quiet, codes, locs, _vars) != 1)
				return -1;
			while (d != e && isspace(*d))
				++d;
			appendCode(o_code, o_locs, codes, locs);
			o_code.push_back((byte)(store ? Instruction::SLOAD : Instruction::MLOAD));
			return 1;
		}
		case '[':
		{
			if (exec)
				return -1;
			bool store = false;
			++d;
			if (*d == '[')
			{
				++d;
				store = true;
			}
			bytes codes;
			vector<unsigned> locs;
			if (compileLispFragment(d, e, _quiet, codes, locs, _vars) != 1)
				return -1;
//.........这里部分代码省略.........
开发者ID:AcriCAA,项目名称:cpp-ethereum,代码行数:101,代码来源:Instruction.cpp

示例6: do_footstep

void sfx::do_footstep() {
    end_sfx_timestamp = std::chrono::high_resolution_clock::now();
    sfx_time = end_sfx_timestamp - start_sfx_timestamp;
    if( std::chrono::duration_cast<std::chrono::milliseconds> ( sfx_time ).count() > 400 ) {
        int heard_volume = sfx::get_heard_volume( g->u.pos() );
        const auto terrain = g->m.ter_at( g->u.pos() ).id.str();
        static std::set<ter_type> const grass = {
            ter_type( "t_grass" ),
            ter_type( "t_shrub" ),
            ter_type( "t_underbrush" ),
        };
        static std::set<ter_type> const dirt = {
            ter_type( "t_dirt" ),
            ter_type( "t_sand" ),
            ter_type( "t_dirtfloor" ),
            ter_type( "t_palisade_gate_o" ),
            ter_type( "t_sandbox" ),
        };
        static std::set<ter_type> const metal = {
            ter_type( "t_ov_smreb_cage" ),
            ter_type( "t_metal_floor" ),
            ter_type( "t_grate" ),
            ter_type( "t_bridge" ),
            ter_type( "t_elevator" ),
            ter_type( "t_guardrail_bg_dp" ),
        };
        static std::set<ter_type> const water = {
            ter_type( "t_water_sh" ),
            ter_type( "t_water_dp" ),
            ter_type( "t_swater_sh" ),
            ter_type( "t_swater_dp" ),
            ter_type( "t_water_pool" ),
            ter_type( "t_sewage" ),
        };
        static std::set<ter_type> const chain_fence = {
            ter_type( "t_chainfence_h" ),
            ter_type( "t_chainfence_v" ),
        };
        if( !g->u.wearing_something_on( bp_foot_l ) ) {
            play_variant_sound( "plmove", "walk_barefoot", heard_volume, 0, 0.8, 1.2 );
            start_sfx_timestamp = std::chrono::high_resolution_clock::now();
            return;
        } else if( grass.count( terrain ) > 0 ) {
            play_variant_sound( "plmove", "walk_grass", heard_volume, 0, 0.8, 1.2 );
            start_sfx_timestamp = std::chrono::high_resolution_clock::now();
            return;
        } else if( dirt.count( terrain ) > 0 ) {
            play_variant_sound( "plmove", "walk_dirt", heard_volume, 0, 0.8, 1.2 );
            start_sfx_timestamp = std::chrono::high_resolution_clock::now();
            return;
        } else if( metal.count( terrain ) > 0 ) {
            play_variant_sound( "plmove", "walk_metal", heard_volume, 0, 0.8, 1.2 );
            start_sfx_timestamp = std::chrono::high_resolution_clock::now();
            return;
        } else if( water.count( terrain ) > 0 ) {
            play_variant_sound( "plmove", "walk_water", heard_volume, 0, 0.8, 1.2 );
            start_sfx_timestamp = std::chrono::high_resolution_clock::now();
            return;
        } else if( chain_fence.count( terrain ) > 0 ) {
            play_variant_sound( "plmove", "clear_obstacle", heard_volume, 0, 0.8, 1.2 );
            start_sfx_timestamp = std::chrono::high_resolution_clock::now();
            return;
        } else {
            play_variant_sound( "plmove", "walk_tarmac", heard_volume, 0, 0.8, 1.2 );
            start_sfx_timestamp = std::chrono::high_resolution_clock::now();
            return;
        }
    }
}
开发者ID:1942rob,项目名称:Cataclysm-DDA,代码行数:69,代码来源:sounds.cpp

示例7: cut

void ViewController::cut()
{
  cout << "Image is " << img_.rows << " rows and " << img_.cols << " cols." << endl;

  HighResTimer hrt("Graph setup");
  hrt.start();

  // -- Put image data into the graph.
  CutSegment graph(img_.cols, img_.rows);
  int num_nodes = img_.rows * img_.cols;
  uchar rchan[num_nodes];
  uchar gchan[num_nodes];
  uchar bchan[num_nodes];
  uchar gray[num_nodes];
  int idx = 0;
  for(int y = 0; y < img_.rows; ++y) {
    for(int x = 0; x < img_.cols; ++x) {
      bchan[idx] = img_.at<cv::Vec3b>(y, x)[0];
      gchan[idx] = img_.at<cv::Vec3b>(y, x)[1];
      rchan[idx] = img_.at<cv::Vec3b>(y, x)[2];
      gray[idx] = img_.at<cv::Vec3b>(y, x)[2];

      ++idx;
    }
  }
  //graph.setImageData(rchan, gchan, bchan);
  graph.setImageData(gray);

  // -- Put seed labels into the graph.
  uchar unl = 0;
  uchar source_id = 1;
  uchar sink_id = 2;
  uchar mask[num_nodes];
  idx = 0;
  for(int y = 0; y < img_.rows; ++y) { 
    for(int x = 0; x < img_.cols; ++x) {
      if(source_points_.count(pair<int, int>(y, x)))
        mask[idx] = source_id;
      else if(sink_points_.count(pair<int, int>(y, x)))
        mask[idx] = sink_id;
      else
        mask[idx] = unl;

      ++idx;
    }
  }
  graph.setSourceSink(mask, source_id, sink_id);

  hrt.stop();
  cout << hrt.reportMilliseconds() << endl;
  
  hrt.reset("planar cut");
  hrt.start();
  graph.segment();
  hrt.stop();
  cout << hrt.reportMilliseconds() << endl;

  cv::Mat output = img_.clone();
  for(int y = 0; y < output.rows; ++y) {
    for(int x = 0; x < output.cols; ++x) {
      if(graph.getLabel(y, x) == CutPlanar::LABEL_SOURCE)
        output.at<cv::Vec3b>(y, x) = img_.at<cv::Vec3b>(y, x);
      else if(graph.getLabel(y, x) == CutPlanar::LABEL_SINK)
        output.at<cv::Vec3b>(y, x) = cv::Vec3b(0, 0, 0);
      else
        output.at<cv::Vec3b>(y, x) = cv::Vec3b(0, 0, 255);
    }
  }

  cv::imshow("output", output);
  view_.cvWaitKey(0);
  cv::destroyWindow("output");
}
开发者ID:chen0510566,项目名称:asp,代码行数:73,代码来源:planar_image_cut.cpp

示例8: symbolExistsInSearchPath

 bool symbolExistsInSearchPath(const std::string& symbol,
                               const std::set<std::string>& searchPathObjects) const
 {
    return searchPathObjects.count(symbol) != 0;
 }
开发者ID:Bangjie,项目名称:rstudio,代码行数:5,代码来源:SessionRParser.hpp

示例9: OnFileChanged

void AudioKaraoke::OnFileChanged(int type, std::set<const AssEntry *> const& changed) {
	if (enabled && (type & AssFile::COMMIT_DIAG_FULL) && (changed.empty() || changed.count(active_line))) {
		LoadFromLine();
		split_area->Refresh(false);
	}
}
开发者ID:liloneum,项目名称:Aegisub,代码行数:6,代码来源:audio_karaoke.cpp

示例10: ammo_effects

void ammo_effects(int x, int y, const std::set<std::string> &effects)
{
    if (effects.count("EXPLOSIVE")) {
        g->explosion(x, y, 24, 0, false);
    }

    if (effects.count("FRAG")) {
        g->explosion(x, y, 12, 28, false);
    }

    if (effects.count("NAPALM")) {
        g->explosion(x, y, 18, 0, true);
    }

    if (effects.count("NAPALM_BIG")) {
        g->explosion(x, y, 72, 0, true);
    }

    if (effects.count("MININUKE_MOD")) {
        g->explosion(x, y, 300, 0, false);
        int junk;
        for (int i = -6; i <= 6; i++) {
            for (int j = -6; j <= 6; j++) {
                if (g->m.sees(x, y, x + i, y + j, 3, junk) &&
                    g->m.move_cost(x + i, y + j) > 0) {
                    g->m.add_field(x + i, y + j, fd_nuke_gas, 3);
                }
            }
        }
    }

    if (effects.count("ACIDBOMB")) {
        for (int i = x - 1; i <= x + 1; i++) {
            for (int j = y - 1; j <= y + 1; j++) {
                g->m.add_field(i, j, fd_acid, 3);
            }
        }
    }

    if (effects.count("EXPLOSIVE_BIG")) {
        g->explosion(x, y, 40, 0, false);
    }

    if (effects.count("EXPLOSIVE_HUGE")) {
        g->explosion(x, y, 80, 0, false);
    }

    if (effects.count("TEARGAS")) {
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                g->m.add_field(x + i, y + j, fd_tear_gas, 3);
            }
        }
    }

    if (effects.count("SMOKE")) {
        for (int i = -1; i <= 1; i++) {
            for (int j = -1; j <= 1; j++) {
                g->m.add_field(x + i, y + j, fd_smoke, 3);
            }
        }
    }
    if (effects.count("SMOKE_BIG")) {
        for (int i = -6; i <= 6; i++) {
            for (int j = -6; j <= 6; j++) {
                g->m.add_field(x + i, y + j, fd_smoke, 18);
            }
        }
    }

    if (effects.count("FLASHBANG")) {
        g->flashbang(x, y);
    }

    if (effects.count("FLAME")) {
        g->explosion(x, y, 4, 0, true);
    }

    if (effects.count("FLARE")) {
        g->m.add_field(x, y, fd_fire, 1);
    }

    if (effects.count("LIGHTNING")) {
        for (int i = x - 1; i <= x + 1; i++) {
            for (int j = y - 1; j <= y + 1; j++) {
                g->m.add_field(i, j, fd_electricity, 3);
            }
        }
    }

    if (effects.count("PLASMA")) {
        for (int i = x - 1; i <= x + 1; i++) {
            for (int j = y - 1; j <= y + 1; j++) {
                if (one_in(2)) {
                    g->m.add_field(i, j, fd_plasma, rng(2, 3));
                }
            }
        }
    }

//.........这里部分代码省略.........
开发者ID:624559299,项目名称:Cataclysm-DDA,代码行数:101,代码来源:damage.cpp

示例11: DoReboot

void DoReboot(unsigned int cmd, const std::string& reason, const std::string& rebootTarget,
              bool runFsck) {
    Timer t;
    LOG(INFO) << "Reboot start, reason: " << reason << ", rebootTarget: " << rebootTarget;

    android::base::WriteStringToFile(StringPrintf("%s\n", reason.c_str()), LAST_REBOOT_REASON_FILE,
                                     S_IRUSR | S_IWUSR, AID_SYSTEM, AID_SYSTEM);

    bool is_thermal_shutdown = false;
    if (cmd == ANDROID_RB_THERMOFF) {
        is_thermal_shutdown = true;
        runFsck = false;
    }

    auto shutdown_timeout = 0ms;
    if (!SHUTDOWN_ZERO_TIMEOUT) {
        if (is_thermal_shutdown) {
            constexpr unsigned int thermal_shutdown_timeout = 1;
            shutdown_timeout = std::chrono::seconds(thermal_shutdown_timeout);
        } else {
            constexpr unsigned int shutdown_timeout_default = 6;
            auto shutdown_timeout_property = android::base::GetUintProperty(
                "ro.build.shutdown_timeout", shutdown_timeout_default);
            shutdown_timeout = std::chrono::seconds(shutdown_timeout_property);
        }
    }
    LOG(INFO) << "Shutdown timeout: " << shutdown_timeout.count() << " ms";

    // keep debugging tools until non critical ones are all gone.
    const std::set<std::string> kill_after_apps{"tombstoned", "logd", "adbd"};
    // watchdogd is a vendor specific component but should be alive to complete shutdown safely.
    const std::set<std::string> to_starts{"watchdogd"};
    ServiceManager::GetInstance().ForEachService([&kill_after_apps, &to_starts](Service* s) {
        if (kill_after_apps.count(s->name())) {
            s->SetShutdownCritical();
        } else if (to_starts.count(s->name())) {
            s->Start();
            s->SetShutdownCritical();
        } else if (s->IsShutdownCritical()) {
            s->Start();  // start shutdown critical service if not started
        }
    });

    Service* bootAnim = ServiceManager::GetInstance().FindServiceByName("bootanim");
    Service* surfaceFlinger = ServiceManager::GetInstance().FindServiceByName("surfaceflinger");
    if (bootAnim != nullptr && surfaceFlinger != nullptr && surfaceFlinger->IsRunning()) {
        ServiceManager::GetInstance().ForEachServiceInClass("animation", [](Service* s) {
            s->SetShutdownCritical();  // will not check animation class separately
        });
    }

    // optional shutdown step
    // 1. terminate all services except shutdown critical ones. wait for delay to finish
    if (shutdown_timeout > 0ms) {
        LOG(INFO) << "terminating init services";

        // Ask all services to terminate except shutdown critical ones.
        ServiceManager::GetInstance().ForEachService([](Service* s) {
            if (!s->IsShutdownCritical()) s->Terminate();
        });

        int service_count = 0;
        // Only wait up to half of timeout here
        auto termination_wait_timeout = shutdown_timeout / 2;
        while (t.duration() < termination_wait_timeout) {
            ServiceManager::GetInstance().ReapAnyOutstandingChildren();

            service_count = 0;
            ServiceManager::GetInstance().ForEachService([&service_count](Service* s) {
                // Count the number of services running except shutdown critical.
                // Exclude the console as it will ignore the SIGTERM signal
                // and not exit.
                // Note: SVC_CONSOLE actually means "requires console" but
                // it is only used by the shell.
                if (!s->IsShutdownCritical() && s->pid() != 0 && (s->flags() & SVC_CONSOLE) == 0) {
                    service_count++;
                }
            });

            if (service_count == 0) {
                // All terminable services terminated. We can exit early.
                break;
            }

            // Wait a bit before recounting the number or running services.
            std::this_thread::sleep_for(50ms);
        }
        LOG(INFO) << "Terminating running services took " << t
                  << " with remaining services:" << service_count;
    }

    // minimum safety steps before restarting
    // 2. kill all services except ones that are necessary for the shutdown sequence.
    ServiceManager::GetInstance().ForEachService([](Service* s) {
        if (!s->IsShutdownCritical()) s->Stop();
    });
    ServiceManager::GetInstance().ReapAnyOutstandingChildren();

    // 3. send volume shutdown to vold
    Service* voldService = ServiceManager::GetInstance().FindServiceByName("vold");
//.........这里部分代码省略.........
开发者ID:darkLord19,项目名称:system-core,代码行数:101,代码来源:reboot.cpp

示例12: run

		virtual Json::Value run(int key, int pid, int sid, const Json::Value &submission)
		{
#ifdef DEBUG
			std::clog << "run" << std::endl;
			std::clog << " pid=" << pid << " sid=" << sid << " key=" << key << std::endl;
#endif
			pthread_mutex_lock(&cntLock);
			if (!boardingPass.count(key))
			{
				pthread_mutex_unlock(&cntLock);
				Json::Value ret;
				ret["error"] = "not preserved";
				return ret;
			}
			boardingPass.erase(boardingPass.find(key));
			runningCnt++, totCnt++;
			const int _totCnt_ = totCnt;
			pthread_mutex_unlock(&cntLock);
			
			Json::Value ret;
			std::ostringstream ss;
			ss << runPath << "/" << _totCnt_;
			std::string runDir = ss.str();
			pthread_mutex_lock(&cmdLock);
#ifdef DEBUG
			std::clog << "mkdir -p "+runDir << std::endl;
#endif
			system(("mkdir -p "+runDir).c_str());
#ifdef DEBUG
			std::clog << "rm -r "+runDir+"/*" << std::endl;
#endif
			system(("rm -r "+runDir+"/*").c_str());
			pthread_mutex_unlock(&cmdLock);
			try
			{
				ss.str("");
				ss << "cp " + dataPath + "/" << pid << "/* " << runDir;
				pthread_mutex_lock(&syncLock);
				if (syncing.count(pid)) pthread_mutex_unlock(&syncLock), throw std::string("data updated when copying files.");
#ifdef DEBUG
				std::clog << ss.str() << std::endl;
#endif
				pthread_mutex_lock(&cmdLock), system(ss.str().c_str()), pthread_mutex_unlock(&cmdLock);
				pthread_mutex_unlock(&syncLock);
				ss.str("");
				ss << "cp " + sourcePath + "/" << sid/10000 << '/' << sid%10000 << "/* " << runDir;
#ifdef DEBUG
				std::clog << ss.str() << std::endl;
#endif
				pthread_mutex_lock(&cmdLock), system((ss.str()).c_str()), pthread_mutex_unlock(&cmdLock);
				ss.str("");
				ss << "./yauj_judge run";
				for (Json::Value::const_iterator i=submission.begin(); i!=submission.end(); i++)
					ss << " " << (*i)["language"].asString() << " " << (*i)["source"].asString();
				ret=dumpCmd(ss.str(),runDir);
#ifndef NCLEAN
				pthread_mutex_lock(&cmdLock), system(("rm -r "+runDir).c_str()), pthread_mutex_unlock(&cmdLock);
#endif
			} catch (std::string &e)
			{
#ifdef DEBUG
				std::clog << " run: catched " << e << std::endl;
#endif
				pthread_mutex_lock(&cntLock);
				runningCnt--, preserveCnt--;
				pthread_mutex_unlock(&cntLock);
				ret["error"] = e;
				return ret;
			}
			pthread_mutex_lock(&cntLock);
			runningCnt--, preserveCnt--;
			pthread_mutex_unlock(&cntLock);
			return ret;
		}
开发者ID:roastduck,项目名称:YAUJ,代码行数:74,代码来源:daemon.cpp

示例13: visitCallImport

 void visitCallImport(CallImport *curr) {
   auto name = curr->target;
   if (visitedTargets.count(name) > 0) return;
   visitedTargets.insert(name);
   std::cout << "  \"" << currFunction->name << "\" -> \"" << name << "\"; // callImport\n";
 }
开发者ID:WebAssembly,项目名称:binaryen,代码行数:6,代码来源:PrintCallGraph.cpp

示例14: visitCall

 void visitCall(Call *curr) {
   auto* target = module->getFunction(curr->target);
   if (visitedTargets.count(target->name) > 0) return;
   visitedTargets.insert(target->name);
   std::cout << "  \"" << currFunction->name << "\" -> \"" << target->name << "\"; // call\n";
 }
开发者ID:WebAssembly,项目名称:binaryen,代码行数:6,代码来源:PrintCallGraph.cpp

示例15: convert

 bool convert(const std::string& method, const std::string& name) {
     return (membersByName.count(std::make_pair(method, name)) > 0);
 }
开发者ID:doriancoins,项目名称:doriancoin,代码行数:3,代码来源:client.cpp


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