本文整理汇总了C++中unordered_set::cbegin方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_set::cbegin方法的具体用法?C++ unordered_set::cbegin怎么用?C++ unordered_set::cbegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unordered_set
的用法示例。
在下文中一共展示了unordered_set::cbegin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printStr
void printStr(const unordered_set<string> &test_set,const int flag){
if (flag==1) {
cout << "nterminal string is :" << endl;
}
else{
cout << "terminal string is :" << endl;
}
for (auto ptr = test_set.cbegin(); ptr!=test_set.cend(); ++ptr) {
cout << *ptr <<endl;
}
cout<<endl;
}
示例2: check_ans
string check_ans(const string &s, unordered_set<string> &D) {
int len = 0;
for (auto iter = D.cbegin(); iter != D.cend(); ++iter) {
int i;
for (i = 0; i < s.size() && i < (*iter).size(); ++i) {
if (s[i] != (*iter)[i]) {
break;
}
}
if (i > len) {
len = i;
}
}
if (len == s.size()) {
return string();
} else {
return s.substr(0, len + 1);
}
}
示例3: extendSubgraph
//--------------------------- PRIVATE: extendSubgraph --------------------------
// Recursively looking size-k subgraphs of the graph.
// Precondition: The graph should have already been built or exists
// Postcondition: The list of subgraphs are displayed
void Graph::extendSubgraph(list<int> &Vsubgraph, unordered_set<int> &Vextension, unordered_set<int> &visited, const int &v, const int &k)
{
if(Vsubgraph.size() == k-1)
{
for(int w : Vextension)
count++;
return;
}
list<int> unvisit;
while(Vextension.size() != 0)
{
int w = *Vextension.cbegin();
Vextension.erase(w);
Vsubgraph.push_back(w);
visited.insert(w);
unvisit.push_back(w);
unordered_set<int> Vextension2 = unordered_set<int>(Vextension);
for (int vertex : vertices[w])
{
if (vertex > v && visited.count(vertex) == 0 && Vextension.count(vertex) == 0)
Vextension2.insert(vertex);
}
extendSubgraph(Vsubgraph, Vextension2, visited, v, k);
Vsubgraph.pop_back();
}
for(int i : unvisit)
visited.erase(i);
}
示例4: pickUpBestOutputValues
//static
void TruthTableUtils::pickUpBestOutputValues(TruthTable* tablePtr, unordered_set<word> inputs,
unordered_set<word> outputs)
{
TruthTable& table = *tablePtr;
// tuning option
const ProgramOptions& options = ProgramOptions::get();
bool pickUpBestOutputOnlyByHammingDistance = options.isTuningEnabled &&
options.options.getBool("pick-up-best-output-only-by-hamming-distance", false);
InputToBestIndexMap inputToBestIndexMap;
deque<DistanceSum> emptyDeque;
for (auto input : inputs)
inputToBestIndexMap[input] = emptyDeque;
while (inputs.size())
{
if (outputs.size() == 1)
{
assert(inputs.size() == 1,
string("TruthTableUtils::pickUpBestOutputValues(): not all outputs were assigned correctly"));
word input = *inputs.cbegin();
word output = *outputs.cbegin();
table[input] = output;
break;
}
updateBestIndicesForInput(&inputToBestIndexMap, inputs, outputs);
word first = *(inputs.cbegin());
word bestOutput = inputToBestIndexMap[first].front().index;
word bestInput = first;
if (pickUpBestOutputOnlyByHammingDistance)
{
// choose best index
int minSum = inputToBestIndexMap[first].front().sum;
for (auto input : inputs)
{
deque<DistanceSum>& sum = inputToBestIndexMap[input];
if (sum.front().index == bestOutput)
{
int currentSum = sum.front().sum;
if (currentSum < minSum)
{
minSum = currentSum;
bestInput = input;
}
}
}
}
else // !pickUpBestOutputOnlyByHammingDistance
{
// find other inputs with the same best pair index
int totalSum = 0;
for (auto input : inputs)
{
deque<DistanceSum>& sum = inputToBestIndexMap[input];
if (sum.front().index == bestOutput)
totalSum += sum.back().sum;
}
// choose best index
int minSum = totalSum - inputToBestIndexMap[first].back().sum;
for (auto input : inputs)
{
deque<DistanceSum>& sum = inputToBestIndexMap[input];
if (sum.front().index == bestOutput)
{
int currentSum = totalSum - sum.back().sum;
if (currentSum < minSum)
{
minSum = currentSum;
bestInput = input;
}
}
}
}
// assign output for best input
table[bestInput] = bestOutput;
// clear map
for (auto iter : inputToBestIndexMap)
{
deque<DistanceSum>& sum = inputToBestIndexMap[iter.first];
if (sum.front().index == bestOutput)
sum.pop_front();
if (sum.back().index == bestOutput)
sum.pop_back();
}
//.........这里部分代码省略.........
示例5: printProdcution
void printProdcution(const string &str, const unordered_set<string> &test_prdtion){
for (auto ptr = test_prdtion.cbegin(); ptr!= test_prdtion.cend(); ++ptr) {
cout << str << "-->" <<*ptr<<endl;
}
cout<<endl;
}