void glpk_wrapper::add(std::unordered_set<Enode *> const & es) { int idx = glp_add_rows(lp, es.size()); for (auto it = es.cbegin(); it != es.cend(); ++it) { set_constraint(idx, *it); idx += 1; } }
std::unordered_set<zsr::filecount> disktree::subtree_closure(zsr::offset nodepos) { std::unordered_set<zsr::filecount> ret{}; const char *inptr = base_ + nodepos; // FIXME Bounds checking const std::unordered_map<std::string, zsr::offset> curchild = children(inptr); const std::unordered_set<zsr::filecount> myval = values(inptr); ret.insert(myval.cbegin(), myval.cend()); for (const std::pair<const std::string, zsr::offset> &child : curchild) { if (child.second == nodepos) throw std::runtime_error{"Loop detected in search tree"}; const std::unordered_set<zsr::filecount> curval = subtree_closure(child.second); ret.insert(curval.cbegin(), curval.cend()); } return ret; }
void PartitionOpLogIndex::AddIndex(const std::unordered_set<int32_t> &oplog_index) { smtx_.lock_shared(); for (auto iter = oplog_index.cbegin(); iter != oplog_index.cend(); iter++) { locks_.Lock(*iter); shared_oplog_index_->insert(*iter, true); locks_.Unlock(*iter); } smtx_.unlock_shared(); }
void QEvalTmpResultCore::filterEdgeListByNodeSet(std::vector<std::pair<idx_t, idx_t> >& edgeList, bool filterLeft, const std::unordered_set<idx_t>& varIdxSet) { std::vector<std::pair<idx_t, idx_t> >::const_iterator edgeIter = edgeList.cbegin(); std::vector<std::pair<idx_t, idx_t> >::iterator edgewIter = edgeList.begin(); if (filterLeft) { while (edgeIter != edgeList.cend()) { if (varIdxSet.find((*edgeIter).first) != varIdxSet.cend()) { *edgewIter = *edgeIter; edgewIter++; } edgeIter++; } } else { while (edgeIter != edgeList.cend()) { if (varIdxSet.find((*edgeIter).second) != varIdxSet.cend()) { *edgewIter = *edgeIter; edgewIter++; } edgeIter++; } } edgeList.erase(edgewIter, edgeList.end()); }
void QEvalTmpResultCore::setEdgeIterNodeUpdate(UniqElemQueue<std::pair<size_t, size_t>>& nodePairQueue, size_t nodeId, size_t otherNodeId, const std::unordered_set<idx_t> &nodeSet) { std::vector<idx_t> newNode; newNode.reserve(nodeSet.size()); newNode.assign(nodeSet.cbegin(), nodeSet.cend()); nodeLists[nodeId] = newNode; nodeHashSets[nodeId] = nodeSet; // push adj nodes except current edge std::vector<size_t>::const_iterator adjNodeIter; const std::vector<size_t> &adjNodeList = graph.getNodeAdjList(nodeId); for (adjNodeIter = adjNodeList.cbegin(); adjNodeIter != adjNodeList.cend(); adjNodeIter++) { if (*adjNodeIter != otherNodeId) { nodePairQueue.push(std::make_pair(nodeId, *adjNodeIter)); } } }
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string example = Strings::format( "The argument should be a substring to search for, or no argument to display all libraries.\n%s", Commands::Help::create_example_string("search png")); args.check_max_arg_count(1, example); const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({OPTION_GRAPH, OPTION_FULLDESC}); auto sources_and_errors = Paragraphs::try_load_all_ports(paths.get_filesystem(), paths.ports); if (!sources_and_errors.errors.empty()) { if (vcpkg::g_debugging) { print_error_message(sources_and_errors.errors); } else { for (auto&& error : sources_and_errors.errors) { System::println( System::Color::warning, "Warning: an error occurred while parsing '%s'", error->name); } System::println(System::Color::warning, "Use '--debug' to get more information about the parse failures.\n"); } } auto& source_paragraphs = sources_and_errors.paragraphs; if (options.find(OPTION_GRAPH) != options.cend()) { const std::string graph_as_string = create_graph_as_string(source_paragraphs); System::println(graph_as_string); Checks::exit_success(VCPKG_LINE_INFO); } if (args.command_arguments.empty()) { for (const auto& source_control_file : source_paragraphs) { do_print(*source_control_file->core_paragraph, options.find(OPTION_FULLDESC) != options.cend()); for (auto&& feature_paragraph : source_control_file->feature_paragraphs) { do_print(source_control_file->core_paragraph->name, *feature_paragraph, options.find(OPTION_FULLDESC) != options.cend()); } } } else { const auto& icontains = Strings::case_insensitive_ascii_contains; // At this point there is 1 argument auto&& args_zero = args.command_arguments[0]; for (const auto& source_control_file : source_paragraphs) { auto&& sp = *source_control_file->core_paragraph; bool contains_name = icontains(sp.name, args_zero); if (contains_name || icontains(sp.description, args_zero)) { do_print(sp, options.find(OPTION_FULLDESC) != options.cend()); } for (auto&& feature_paragraph : source_control_file->feature_paragraphs) { if (contains_name || icontains(feature_paragraph->name, args_zero) || icontains(feature_paragraph->description, args_zero)) { do_print(sp.name, *feature_paragraph, options.find(OPTION_FULLDESC) != options.cend()); } } } } System::println( "\nIf your library is not listed, please open an issue at and/or consider making a pull request:\n" " https://github.com/Microsoft/vcpkg/issues"); Checks::exit_success(VCPKG_LINE_INFO); }
static bool is_in(const T x, const std::unordered_set<T>& xs) { return(xs.find(x) != xs.cend()); }
bool is_visited(std::string state) const { return visited_list.cend() != std::find(visited_list.cbegin(), visited_list.cend(), state); }
void KeyMultiValueTagFilter::setValues(const std::unordered_set<std::string> & values) { setValues(values.cbegin(), values.cend()); }
// Function to randomly populate a topic void populateTopic(const unsigned long long int &a_num_words, const std::unordered_set<std::string> &a_vocabulary) { d_word_topic_allocations.reserve(a_vocabulary.size()); // Make the map the size of the vocabulary unsigned long long int l_unallocated_number_of_words = a_num_words; // Number of words not yet allocated unsigned int l_unallocated_words_in_topic = a_vocabulary.size(); // Number of words for each topic distribution unsigned l_seed = std::chrono::system_clock::now().time_since_epoch().count(); // Seed generator for randomly allocating words in topic std::default_random_engine l_generator (l_seed); // Seed generator unsigned long long int l_new_words_allocated; // Temporary variable counting number of words allocated for current topic during an iteration for (std::unordered_set<std::string>::const_iterator it = a_vocabulary.cbegin(); it!=a_vocabulary.cend(); ++it) { l_new_words_allocated = newBinomial(l_unallocated_number_of_words,l_unallocated_words_in_topic,l_generator); // Number of words allocated for current iteration d_word_topic_allocations[*it] = l_new_words_allocated; // Update map with the number of allocations for that word --l_unallocated_words_in_topic; // Decrement the number of words in the topic not yet allocated to l_unallocated_number_of_words -= l_new_words_allocated; // Decrease the number of words not yet allocated by the number allocated this iteration if (l_unallocated_number_of_words==0) {break;} // If no more words left to allocate, break } };