本文整理汇总了C++中std::unordered_set::count方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_set::count方法的具体用法?C++ unordered_set::count怎么用?C++ unordered_set::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::unordered_set
的用法示例。
在下文中一共展示了unordered_set::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handlesElement
bool PolygonElementParser::handlesElement(const NodeType::XMLNode& node) const
{
if (!typeIDSetInitialized) {
std::lock_guard<std::mutex> lock(polygonElementParser_initializedTypeIDMutex);
if(!typeIDSetInitialized) {
typeIDSet.insert(NodeType::GML_TriangleNode.typeID());
typeIDSet.insert(NodeType::GML_RectangleNode.typeID());
typeIDSet.insert(NodeType::GML_PolygonNode.typeID());
typeIDSet.insert(NodeType::GML_PolygonPatchNode.typeID());
typeIDSetInitialized = true;
}
}
return typeIDSet.count(node.typeID()) > 0;
}
示例2: should_rename
bool should_rename(DexClass *clazz,
std::vector<std::string>& pre_patterns,
std::vector<std::string>& post_patterns,
std::unordered_set<const DexType*>& untouchables,
bool rename_annotations) {
if (!rename_annotations && is_annotation(clazz)) return false;
if (untouchables.count(clazz->get_type())) return false;
auto chstring = clazz->get_type()->get_name()->c_str();
/* We're assuming anonymous classes are safe always safe to rename. */
auto substr = strrchr(chstring, '$');
if (substr != nullptr) {
auto val = *++substr;
if (val >= '0' && val <= '9') {
match_inner++;
return true;
}
}
/* Check for more aggressive, but finer grained filters first */
for (auto p : pre_patterns) {
auto substr = strstr(chstring, p.c_str());
if (substr != nullptr) {
if (p.length() > 1) {
match_long++;
} else {
match_short++;
}
return true;
}
}
if (!can_rename(clazz) && !can_delete(clazz)) {
return false;
}
/* Check for wider, less precise filters */
for (auto p : post_patterns) {
auto substr = strstr(chstring, p.c_str());
if (substr != nullptr) {
if (p.length() > 1) {
match_long++;
} else {
match_short++;
}
return true;
}
}
return false;
}
示例3: expandSpontaneous
void Regex::expandSpontaneous(std::unordered_set<std::size_t>& states) const {
std::queue<std::size_t> queue;
for (auto& state : states) {
queue.push(state);
}
while (!queue.empty()) {
std::size_t state = queue.front();
queue.pop();
for (std::size_t index : stateList[state].spontaneous) {
if (states.count(index) == 0) {
states.insert(index);
queue.push(index);
}
}
}
}
示例4: GetBodyAt
SparseArray3<Body>::Iterator GetBodyAt(Vec3i position) {
auto it = bodies.begin();
for(; it != bodies.end(); it++) {
if(!it->destroyable->alive) {
if(eatables.count(it.getHandle()))
eatables.erase(it.getHandle());
if(pushables.count(it.getHandle()))
pushables.erase(it.getHandle());
UnreferenceDestroyable(it->destroyable);
bodies.remove(it);
continue;
}
if(it->position == position)
return it;
}
return it;
}
示例5: xrelevance
double xrelevance(const MLNetworkSharedPtr& mnet, const ActorSharedPtr& actor, const std::unordered_set<LayerSharedPtr>& layers, edge_mode mode) {
set<actor_id> neighbors_on_selected_layers;
set<actor_id> neighbors_on_other_layers;
set<actor_id> all_neighbors;
for (NodeSharedPtr node: *mnet->get_nodes(actor)) {
for (NodeSharedPtr neighbor: *mnet->neighbors(node, mode)) {
all_neighbors.insert(neighbor->actor->id);
if (layers.count(neighbor->layer)>0)
neighbors_on_selected_layers.insert(neighbor->actor->id);
else neighbors_on_other_layers.insert(neighbor->actor->id);
}
}
if (all_neighbors.size()==0) return 0; // by definition
else {
for (actor_id actor: neighbors_on_other_layers)
neighbors_on_selected_layers.erase(actor);
return (double)neighbors_on_selected_layers.size()/all_neighbors.size();
}
}
示例6: defValNeedsVariable
bool PhpParam::defValNeedsVariable() const {
if (defVal.empty() || !isTypeCppIndirectPass(cppType)) {
return false;
}
if (cppType == "HPHP::String const&" && (defVal == "empty_string" ||
defVal == "null_string")) {
return false;
} else if (cppType == "HPHP::String const&" &&
g_knownStringConstants.count(defVal) > 0) {
return false;
} else if (cppType == "HPHP::Array const&" && defVal == "null_array") {
return false;
} else if (cppType == "HPHP::Object const&" && defVal == "null_object") {
return false;
} else if (cppType == "HPHP::Variant const&" && defVal == "null_variant") {
return false;
}
return true;
}
示例7: addNode
void Pedigree::addNode(std::unordered_set<OrganismSpecifier>& set, const OrganismSpecifier& newNode) {
// First check for exact match via hash-collision and equality
if (set.count(newNode) > 0) return;
// Now check for equality with something existing
for (auto& node : set) {
if (node == newNode) {
// See if the new node adds some more information and take this into account
if (node.name().empty() && !newNode.name().empty()) {
set.erase(node);
set.insert(newNode);
}
return;
}
}
// If nothing found then just insert the new node as given
set.insert(newNode);
}
示例8: cancelAll
size_t ExpiryTimerImpl::cancelAll(
const std::unordered_set< std::shared_ptr<TimerTask > >& tasks)
{
std::lock_guard< std::mutex > lock{ m_mutex };
size_t erased { 0 };
for(auto it = m_tasks.begin(); it != m_tasks.end();)
{
if(tasks.count(it->second))
{
it = m_tasks.erase(it);
++erased;
}
else
{
++it;
}
}
return erased;
}
示例9: keep_faces
void mesh::keep_faces(std::unordered_set<int> & to_keep, aiScene * s) {
aiMesh * mesh = s->mMeshes[0];
int num_new = 0;
aiFace * new_faces = new aiFace[mesh->mNumFaces];
// For each face in the mesh
for (int i = 0; i < mesh->mNumFaces; ++i) {
// If this face is in to_keep keep it
if (to_keep.count(i) > 0) {
new_faces[num_new] = mesh->mFaces[i];
++num_new;
}
}
delete[] mesh->mFaces;
mesh->mNumFaces = num_new;
mesh->mFaces = std::move(new_faces);
}
示例10: checkIrreducibleCFG
// Use DFS to detect a possible loop, most likely an loop in an irreducible
// CFG. One of the headers of the loop is the FirstBB.
// Loop is set to true upon successfully detecting such a loop.
void ExprBuilder::checkIrreducibleCFG(BasicBlock *BB,
BasicBlock *FirstBB,
std::unordered_set<const BasicBlock *> &VisitedBBs,
bool &Loop) {
VisitedBBs.insert(BB);
for (succ_iterator PI = succ_begin(BB), E = succ_end(BB);
PI != E; ++PI) {
BasicBlock *Succ = *PI;
if (Succ == FirstBB) {
Loop = true;
}
else if (VisitedBBs.count(Succ)) {
continue;
}
else {
checkIrreducibleCFG(Succ, FirstBB, VisitedBBs, Loop);
}
if (Loop)
return;
}
}
示例11: load_mods_list
void mod_manager::load_mods_list(WORLDPTR world) const
{
if (world == NULL) {
return;
}
std::vector<std::string> &amo = world->active_mod_order;
amo.clear();
std::ifstream mods_list_file( get_mods_list_file(world).c_str(),
std::ios::in | std::ios::binary );
if (!mods_list_file) {
return;
}
bool obsolete_mod_found = false;
try {
JsonIn jsin(mods_list_file);
JsonArray ja = jsin.get_array();
while (ja.has_more()) {
const std::string mod = ja.next_string();
if( mod.empty() || std::find(amo.begin(), amo.end(), mod) != amo.end() ) {
continue;
}
if( obsolete_mod_list.count( mod ) ) {
obsolete_mod_found = true;
continue;
}
amo.push_back(mod);
}
} catch (std::string e) {
DebugLog( D_ERROR, DC_ALL ) << "worldfactory: loading mods list failed: " << e;
}
if( obsolete_mod_found ) {
// If we found an obsolete mod, overwrite the mod list without the obsolete one.
save_mods_list(world);
}
}
示例12: select_single_called
/**
* Add to the list the single called.
*/
void SimpleInlinePass::select_single_called(
Scope& scope, std::unordered_set<DexMethod*>& methods) {
std::unordered_map<DexMethod*, int> calls;
for (const auto& method : methods) {
calls[method] = 0;
}
// count call sites for each method
walk_opcodes(scope, [](DexMethod* meth) { return true; },
[&](DexMethod* meth, DexInstruction* insn) {
if (is_invoke(insn->opcode())) {
auto mop = static_cast<DexOpcodeMethod*>(insn);
auto callee = resolve_method(
mop->get_method(), opcode_to_search(insn), resolved_refs);
if (callee != nullptr && callee->is_concrete()
&& methods.count(callee) > 0) {
calls[callee]++;
}
}
});
// pick methods with a single call site and add to candidates.
// This vector usage is only because of logging we should remove it
// once the optimization is "closed"
std::vector<std::vector<DexMethod*>> calls_group(MAX_COUNT);
for (auto call_it : calls) {
if (call_it.second >= MAX_COUNT) {
calls_group[MAX_COUNT - 1].push_back(call_it.first);
continue;
}
calls_group[call_it.second].push_back(call_it.first);
}
assert(method_breakup(calls_group));
for (auto callee : calls_group[1]) {
inlinable.insert(callee);
}
}
示例13: parse_db_arguments
int parse_db_arguments(const std::string& db_arg_str, std::string& db_type, int& db_flags)
{
std::vector<std::string> db_args;
boost::split(db_args, db_arg_str, boost::is_any_of("#"));
db_type = db_args.front();
boost::algorithm::trim(db_type);
if (db_args.size() == 1)
{
return 0;
}
else if (db_args.size() > 2)
{
std::cerr << "unrecognized database argument format: " << db_arg_str << ENDL;
return 1;
}
std::string db_arg_str2 = db_args[1];
boost::split(db_args, db_arg_str2, boost::is_any_of(","));
// optionally use a composite mode instead of individual flags
const std::unordered_set<std::string> db_modes {"safe", "fast", "fastest"};
std::string db_mode;
if (db_args.size() == 1)
{
if (db_modes.count(db_args[0]) > 0)
{
db_mode = db_args[0];
}
}
if (! db_mode.empty())
{
db_flags = get_db_flags_from_mode(db_mode);
}
return 0;
}
示例14: stepFunction
void stepFunction(
const std::unordered_set<unsigned int>& excitatory_neurons,
double ***state,
const unsigned int ind_old,
const unsigned int ind_new,
double *state_K1,
double *state_K2,
double *state_K3,
double *state_K4,
double *state_temp_1,
double *state_temp_2,
double *state_temp_3,
const double *sumFootprintAMPA,
const double *sumFootprintNMDA,
const double *sumFootprintGABAA,
const unsigned int numNeurons,
const unsigned int stateSize,
const double dt,
std::vector<double> *spikeTimes_e,
std::vector<double> *spikeNeuronIndices_e,
std::vector<double> *spikeTimes_i,
std::vector<double> *spikeNeuronIndices_i,
const unsigned int firstNeuron,
const unsigned int lastNeuron
)
{
for (unsigned int indexOfNeuron = firstNeuron; indexOfNeuron < lastNeuron;
indexOfNeuron += 1)
{
if (excitatory_neurons.count(indexOfNeuron))
{
state[ind_new][indexOfNeuron][0] =
state[ind_old][indexOfNeuron][0] + 1;
runge_kutta_generic(
(const double **)state[ind_old],
state_K1,
state_K2,
state_K3,
state_K4,
state_temp_1,
state_temp_2,
state_temp_3,
numNeurons,
stateSize,
indexOfNeuron,
1,
sumFootprintAMPA,
sumFootprintNMDA,
sumFootprintGABAA,
dt,
(*golomb::f_dV_dt),
state[ind_new][indexOfNeuron]);
runge_kutta((*golomb::f_I_Na_dh_dt), 2);
runge_kutta((*golomb::f_dn_dt), 3);
runge_kutta((*golomb::f_dz_dt), 4);
runge_kutta((*golomb::f_dsAMPA_dt), 5);
runge_kutta((*golomb::f_dxNMDA_dt), 6);
runge_kutta((*golomb::f_dsNMDA_dt), 7);
state[ind_new][indexOfNeuron][8] =
state[ind_old][indexOfNeuron][8];
state[ind_new][indexOfNeuron][9] =
state[ind_old][indexOfNeuron][9];
if (((int)state[ind_new][indexOfNeuron][1]) >= 20)
{
#ifdef USE_STD_THREADS
std::lock_guard<std::mutex> lk(m);
#endif // ifdef USE_STD_THREADS
spikeTimes_e->push_back(
(state[ind_new][indexOfNeuron][0]) * dt);
spikeNeuronIndices_e->push_back(indexOfNeuron);
}
} else {
state[ind_new][indexOfNeuron][0] =
state[ind_old][indexOfNeuron][0] + 1;
runge_kutta_generic(
(const double **)state[ind_old],
state_K1,
state_K2,
state_K3,
state_K4,
state_temp_1,
state_temp_2,
state_temp_3,
numNeurons,
stateSize,
indexOfNeuron,
1,
sumFootprintAMPA,
sumFootprintNMDA,
sumFootprintGABAA,
dt,
(*wang_buzsaki::f_dV_dt),
state[ind_new][indexOfNeuron]);
runge_kutta((*wang_buzsaki::f_I_Na_dh_dt), 2);
runge_kutta((*wang_buzsaki::f_I_Kdr_dn_dt), 3);
state[ind_new][indexOfNeuron][4] =
state[ind_old][indexOfNeuron][4];
state[ind_new][indexOfNeuron][5] =
state[ind_old][indexOfNeuron][5];
//.........这里部分代码省略.........
示例15: allow_ext_entity_protocol
static bool allow_ext_entity_protocol(const String& protocol) {
return s_ext_entity_whitelist.count(protocol.get());
}