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


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

本文整理汇总了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;
    }
开发者ID:j-o,项目名称:libcitygml,代码行数:16,代码来源:polygonelementparser.cpp

示例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;
}
开发者ID:476139183,项目名称:redex,代码行数:46,代码来源:RenameClasses.cpp

示例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);
            }
        }
    }
}
开发者ID:Ghabriel,项目名称:FormalLanguageUtils,代码行数:17,代码来源:Regex.cpp

示例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;
}
开发者ID:Flaise,项目名称:sfml_components,代码行数:19,代码来源:body.hpp

示例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();
	}
}
开发者ID:magnanim,项目名称:mlnetwork,代码行数:19,代码来源:relevance.cpp

示例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;
}
开发者ID:rattfieldnz,项目名称:hiphop-php,代码行数:20,代码来源:idl.cpp

示例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);
}
开发者ID:elderfd,项目名称:GeneDrop,代码行数:20,代码来源:Pedigree.cpp

示例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;
        }
开发者ID:WojciechLuczkow,项目名称:iotivity,代码行数:20,代码来源:ExpiryTimerImpl.cpp

示例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);
}
开发者ID:lzbotha,项目名称:hons-project,代码行数:20,代码来源:mesh.cpp

示例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;
  }
}
开发者ID:Gardenya,项目名称:souper,代码行数:24,代码来源:Candidates.cpp

示例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);
    }
}
开发者ID:Camkitsune,项目名称:Cataclysm-DDA,代码行数:36,代码来源:mod_manager.cpp

示例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);
  }
}
开发者ID:Andy10101,项目名称:redex,代码行数:39,代码来源:SimpleInline.cpp

示例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;
}
开发者ID:monero-project,项目名称:bitmonero,代码行数:36,代码来源:blockchain_import.cpp

示例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];
//.........这里部分代码省略.........
开发者ID:nebw,项目名称:gsoc2012,代码行数:101,代码来源:gsoc-c.cpp

示例15: allow_ext_entity_protocol

static bool allow_ext_entity_protocol(const String& protocol) {
  return s_ext_entity_whitelist.count(protocol.get());
}
开发者ID:KOgames,项目名称:hhvm,代码行数:3,代码来源:ext_libxml.cpp


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