Esempio n. 1
0
	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;
	}
Esempio n. 2
0
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;
    }
}
Esempio n. 3
0
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();
}
Esempio n. 4
0
  // 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
      }
  };
Esempio n. 5
0
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));
		}
	}
}
Esempio n. 6
0
 bool is_visited(std::string state) const
 {
     return visited_list.cend() != std::find(visited_list.cbegin(), visited_list.cend(), state);
 }
Esempio n. 7
0
void KeyMultiValueTagFilter::setValues(const std::unordered_set<std::string> & values)
{
	setValues(values.cbegin(), values.cend());
}