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


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

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


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

示例1: set_union

	void set_union(std::unordered_set<key_type>& key1,
                   std::unordered_set<key_type>& key2, 
                   std::unordered_set<key_type>& final_set) {
		for(auto it = key1.begin(); it != key1.end(); ++it) {
			final_set.insert(*it);
		}
		for(auto it = key2.begin(); it != key2.end(); ++it) {
			final_set.insert(*it);
		}
	}
开发者ID:mgentili,项目名称:SetReconciliation,代码行数:10,代码来源:IBLT_helpers.hpp

示例2: BM_lookupEventFormat

/*
 *	Measure the time it takes for android_lookupEventFormat_len
 */
static void BM_lookupEventFormat(benchmark::State& state) {
  prechargeEventMap();

  std::unordered_set<uint32_t>::const_iterator it = set.begin();

  while (state.KeepRunning()) {
    size_t len;
    android_lookupEventFormat_len(map, &len, (*it));
    ++it;
    if (it == set.end()) it = set.begin();
  }
}
开发者ID:android,项目名称:platform_system_core,代码行数:15,代码来源:liblog_benchmark.cpp

示例3:

void DirectedGraph<T>::
insert(T const &node, std::unordered_set<T> const &adjacent)
{
    _nodes.insert(node);
    _nodes.insert(adjacent.begin(), adjacent.end());

    auto it = _adjacency.find(node);
    if (it == _adjacency.end()) {
        _adjacency.insert(std::make_pair(node, adjacent));
    } else {
        it->second.insert(adjacent.begin(), adjacent.end());
    }
}
开发者ID:roman-dzieciol,项目名称:xcbuild,代码行数:13,代码来源:DirectedGraph.cpp

示例4: queryGen_

std::vector<FocusedIntervalQuery> ExpSetupHelper::genSearchQueries(vector<std::vector<std::string> > templates,
                                                                   double queryZipfParam,
                                                                   int numQueries,
                                                                   uint64_t& tsStart,
                                                                   uint64_t& tsEnd,
                                                                   double delta,
                                                                   std::unordered_set<int64_t> const & vertices)
{
    std::vector<core::FocusedIntervalQuery> queries;

    std::vector<int64_t> vertexList;
    std::copy(vertices.begin(), vertices.end(),
               std::back_inserter(vertexList));

    int numQueryTypes = templates.size();
    util::ZipfRand queryGen_(queryZipfParam, numQueryTypes);
    unsigned seed = time(NULL);
    queryGen_.setSeed(seed++);

    // use a random start node for the interval query
    size_t vertexIdMean = (vertices.size()) / 2;
    double vertexIdStdDev = vertexIdMean - 1;
    util::NormalRand vertexIdGen(vertexIdMean, vertexIdStdDev,
                           0, vertices.size()-1);


    // use a random start time for the interval query
    double offset = (delta * (tsEnd - tsStart));

    size_t timeMean = tsStart + (((tsEnd - offset) - tsStart) / 2);

    double timeStdDev = timeMean - 1;
    util::NormalRand timeGen(timeMean, timeStdDev,
                           tsStart, tsStart+offset);



    std::cout << "tsStart " << tsStart << std::endl;
    std::cout << "tsEnd " << tsEnd << std::endl;
    std::cout << "timeMean " << timeMean << std::endl;
    std::cout << "offset " << offset << std::endl;

    int vertexIndex;
    int templateIndex;
    uint64_t start;
    uint64_t end;

    VertexId vi;
    for (int i = 0; i < numQueries; i++) {
        templateIndex = numQueryTypes > 1 ? queryGen_.getRandomValue() : 0;
        vertexIndex = vertexIdGen.getRandomValue();
        start = timeGen.getRandomValue();
        end = start + offset;
        vi = vertexList.at(vertexIndex);
        std::cout << "start " << start << std::endl;
        queries.push_back(FocusedIntervalQuery(
                              vi, start, end, templates[templateIndex]));
    }
    return queries;
}
开发者ID:xiaomailong,项目名称:railwaydb,代码行数:60,代码来源:ExpSetupHelper.cpp

示例5: format

void repository::distributor::create_recursively(
    const boost::filesystem::path &root, const bool strip) {
  try {
    std::unordered_set<std::string> ignore;
    const boost::filesystem::path index_path = root / format().name.get_index();
    if (boost::filesystem::is_regular_file(index_path)) {
      BUNSAN_LOG_DEBUG << "Found index file at " << root
                       << ", trying to create source package...";
      ignore.insert(format().name.get_index());
      create(root, strip);
      index index_;
      index_.load(index_path);
      const std::unordered_set<std::string> sources = index_.sources();
      ignore.insert(sources.begin(), sources.end());
    }
    for (boost::filesystem::directory_iterator i(root), end; i != end; ++i) {
      if (boost::filesystem::is_directory(*i) &&
          ignore.find(i->path().filename().string()) == ignore.end()) {
        create_recursively(i->path(), strip);
      }
    }
  } catch (distributor_create_recursively_error &) {
    throw;
  } catch (std::exception &) {
    BOOST_THROW_EXCEPTION(distributor_create_recursively_error()
                          << distributor_create_recursively_error::root(root)
                          << distributor_create_recursively_error::strip(strip)
                          << enable_nested_current());
  }
}
开发者ID:bunsanorg,项目名称:pm,代码行数:30,代码来源:distributor.cpp

示例6: doWalkFunction

 void doWalkFunction(Function* func) {
   Flat::verifyFlatness(func);
   // Build the data-flow IR.
   graph.build(func, getModule());
   nodeUsers.build(graph);
   // Propagate optimizations through the graph.
   std::unordered_set<DataFlow::Node*> optimized; // which nodes we optimized
   for (auto& node : graph.nodes) {
     workLeft.insert(node.get()); // we should try to optimize each node
   }
   while (!workLeft.empty()) {
     //std::cout << "\n\ndump before work iter\n";
     //dump(graph, std::cout);
     auto iter = workLeft.begin();
     auto* node = *iter;
     workLeft.erase(iter);
     workOn(node);
   }
   // After updating the DataFlow IR, we can update the sets in
   // the wasm.
   // TODO: we also need phis, as a phi can flow directly into say
   //       a return or a call parameter.
   for (auto* set : graph.sets) {
     auto* node = graph.setNodeMap[set];
     auto iter = optimized.find(node);
     if (iter != optimized.end()) {
       assert(node->isExpr()); // this is a set, where the node is defined
       set->value = node->expr;
     }
   }
 }
开发者ID:aheejin,项目名称:binaryen,代码行数:31,代码来源:DataFlowOpts.cpp

示例7: chooseVictim

 inline DirectedGraph::node_id chooseVictim(
     const std::unordered_set<DirectedGraph::node_id> &nodes_set) const {
   // TODO(Hakan): This is very inefficient scheme, however in the
   //              future, we can use the transaction's priority
   //              as the victim selection parameter.
   return *(nodes_set.begin());
 }
开发者ID:HanumathRao,项目名称:incubator-quickstep,代码行数:7,代码来源:CycleDetector.hpp

示例8:

	VectorCodec(std::string corpus, int vecLength = 0) {
		for (int i = 0; i < corpus.length(); i++) {
			alphabet.emplace(corpus[i]);
		}
		nSymbols = alphabet.size();
				
		if (vecLength == 0) { //auto
			N = nSymbols;
		} else {
			N = vecLength;
		}
		vector.resize(N, 0.0f);
		
		for (int i = 0; i < 256; i++) { tableStoI[i] = 0; tableItoS[i] = 0; }
		
		int index = 0;
		for (auto itr = alphabet.begin(); itr != alphabet.end(); ++itr) {
			tableStoI[*itr] = index;
			tableItoS[index] = *itr;
			index++;
		}
		
		symbol = 0;
		symIndex = 0;
	}
开发者ID:222464,项目名称:NeoRL-CPU,代码行数:25,代码来源:TextPrediction.cpp

示例9: predict

double predict(const std::unordered_map<double, std::vector<double> > &model,
               const std::unordered_set<double> &label_set,
               const std::vector<double> &feats)
{
    // binary classification
    if (model.size() == 1) {
        std::unordered_set<double>::const_iterator lit = label_set.begin();
        const double label1 = *(lit++);
        const double label2 = *lit;
        const std::unordered_map<double, std::vector<double> >::const_iterator mit = model.find(label1);
        assert(mit != model.end());

        return hypothesis(mit->second, feats) > 0.5 ? label1 : label2;
    }

    double max_hyp = -1;
    double max_label = -1;
    for (std::unordered_map<double, std::vector<double> >::const_iterator it = model.begin();
         it != model.end();
         ++it)
    {
        double hyp = hypothesis(it->second, feats);
        if (hyp > max_hyp) {
            max_hyp = hyp;
            max_label = it->first;
        }
    }
    assert(max_hyp != -1);
    assert(max_label != -1);

    return max_label;
}
开发者ID:abhinav04sharma,项目名称:logistic_regression_mpi,代码行数:32,代码来源:logistic_regression.cpp

示例10: add_timers

// Add a collection of timers to the data store.  The collection is emptied by
// this operation, since the timers are now owned by the store.
void TimerStore::add_timers(std::unordered_set<Timer*>& set)
{
  for (auto it = set.begin(); it != set.end(); ++it)
  {
    add_timer(*it);
  }
  set.clear();
}
开发者ID:plfrancis,项目名称:chronos,代码行数:10,代码来源:timer_store.cpp

示例11: answer

std::unordered_set<uint64_t> Union::operator() (const std::unordered_set<uint64_t>& first, const std::unordered_set<uint64_t>& second)
{
    std::unordered_set<uint64_t> answer(first);
    std::for_each(second.begin(), second.end(), [&answer] (const uint64_t val) {
             answer.insert(val);
             });
    return answer;
}
开发者ID:drzeus99,项目名称:PPB-2.0,代码行数:8,代码来源:union.cpp

示例12: findIncludeFile

std::string findIncludeFile(std::string includeFileName, std::ostream& os, std::unordered_set<std::string>& includeSearchDirs)
{
    for(auto it = includeSearchDirs.begin(); it != includeSearchDirs.end(); ++it) 
    {
        boost::filesystem::path pathToFile(*it);
        pathToFile /= includeFileName;
        if(boost::filesystem::exists(pathToFile) && boost::filesystem::is_regular_file(pathToFile))
        {
            boost::filesystem::absolute(pathToFile);
            return pathToFile.string();
        }
    }
    std::cerr << "include file " << includeFileName << " not found, search path was: ";
    for(auto it = includeSearchDirs.begin(); it != includeSearchDirs.end(); ++it) 
        std::cerr << *it << " ";
    std::cerr << std::endl;
    exit(-1);
}
开发者ID:c3di,项目名称:ettention,代码行数:18,代码来源:CompileKernel.cpp

示例13: shareAnElement

/*
 *	Determine whether two sets share any elements.
 */
bool Prover::shareAnElement(const std::unordered_set<SddLiteral>& firstSet,
					const std::unordered_set<SddLiteral>& secondSet) {
	if (firstSet.size() < secondSet.size()) {
		for (std::unordered_set<SddLiteral>::const_iterator it = firstSet.begin(); it != firstSet.end(); ++it) {
			if (secondSet.count(*it) != 0) {
				return true;
			}
		}
		return false;
	} else {
		for (std::unordered_set<SddLiteral>::const_iterator it = secondSet.begin(); it != secondSet.end(); ++it) {
			if (firstSet.count(*it) != 0) {
				return true;
			}
		}
		return false;
	}
}
开发者ID:tpagram,项目名称:sddtab,代码行数:21,代码来源:prover.cpp

示例14: set_difference

	// Returns all the keys in keys1 - keys2
	void set_difference(std::unordered_set<key_type>& keys1, 
                        std::unordered_set<key_type>& keys2, 
                        std::unordered_set<key_type>& result) {
		for(auto it = keys1.begin(); it != keys1.end(); ++it) {
			if( keys2.find(*it) == keys2.end() ) {
				result.insert(*it);
			}
		}
	}
开发者ID:mgentili,项目名称:SetReconciliation,代码行数:10,代码来源:IBLT_helpers.hpp

示例15: set_intersection

	void set_intersection(std::unordered_set<key_type>& key1, 
                          std::unordered_set<key_type>& key2, 
                          std::unordered_set<key_type>& intersection) {
		for(auto it1 = key1.begin(); it1 != key1.end(); ++it1) {
			if( key2.find(*it1) != key2.end() ) {
				intersection.insert(*it1);
			}
		}
	}
开发者ID:mgentili,项目名称:SetReconciliation,代码行数:9,代码来源:IBLT_helpers.hpp


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