本文整理汇总了C++中yvector::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ yvector::begin方法的具体用法?C++ yvector::begin怎么用?C++ yvector::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yvector
的用法示例。
在下文中一共展示了yvector::begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SubstituteByMultiWord
void CMultiWordCreator::SubstituteByMultiWord(SWordHomonymNum& WordHomonymNum, yvector<SWordHomonymNum>& WordIndexes)
{
const CWord& multi_word = m_Words.GetWord(WordHomonymNum);
int k1 = -1, k2 = -1;
for (size_t i = 0; i < WordIndexes.size(); i++) {
const CWord& w = m_Words.GetWord(WordIndexes[i]);
if ((w.IsOriginalWord()) &&
(w.GetSourcePair().FirstWord() == multi_word.GetSourcePair().FirstWord()))
k1 = i;
if (k1 != -1) {
if (!w.IsOriginalWord())
break;
if (w.GetSourcePair().FirstWord() == multi_word.GetSourcePair().LastWord()) {
k2 = i;
break;
}
}
}
if ((k1 != -1) && (k2 != -1))
for (int j = k2; j >= k1; j--)
WordIndexes.erase(WordIndexes.begin() + j);
if (k1 != -1)
WordIndexes.insert(WordIndexes.begin() + k1, WordHomonymNum);
}
示例2: BuildRuleInfo
static void BuildRuleInfo(const yset<CWorkRule>& rules, yvector<CGLRRuleInfo>& res)
{
res.clear();
for (yset<CWorkRule>::const_iterator it = rules.begin(); it != rules.end(); ++it) {
res.push_back();
res.back().Init(&*it);
}
std::sort(res.begin(), res.end());
}
示例3: SolveAmbiguity
void SolveAmbiguity(yvector<COccurrence>& Occurrences, yvector<size_t>& res)
{
if (Occurrences.size() == 0)
return;
if (Occurrences.size() == 1) {
res.push_back(0);
return;
}
std::sort(Occurrences.begin(), Occurrences.end(), SortByRightBorderPredicate);
yvector<CPeriodSolutionWeight> solutions(Occurrences.size());
for (size_t i = 0; i < Occurrences.size(); ++i) {
const COccurrence& cur_occurrence = Occurrences[i];
const CPeriodSolutionWeight* best_overlapping_solution = NULL;
const CPeriodSolutionWeight* best_non_overlapping_solution = NULL;
for (int j = i - 1; j >= 0; --j)
if (Occurrences[j].second <= cur_occurrence.first) //does not intersect
{
best_non_overlapping_solution = &(solutions[j]);
break;
} else if (best_overlapping_solution == NULL || *best_overlapping_solution < solutions[j])
best_overlapping_solution = &(solutions[j]);
CPeriodSolutionWeight& cur_solution = solutions[i];
if (best_non_overlapping_solution == NULL)
cur_solution.m_VirtualGroup.SetPair(cur_occurrence.first, cur_occurrence.first);
else
cur_solution = *best_non_overlapping_solution; // nasty copying!
cur_solution.AddOccurrence(cur_occurrence, i);
//if overlapped solution is still better
if (best_overlapping_solution != NULL && cur_solution < *best_overlapping_solution)
cur_solution = *best_overlapping_solution; // nasty copying again!
}
CPeriodSolutionWeight& best_solution = solutions.back();
res.swap(best_solution.m_Solution);
}
示例4: SolveAmbiguity_Old
void SolveAmbiguity_Old(yvector< COccurrence >& Occurrences)
{
//previous version of disambiguation - it is quite slower in worst cases
sort (Occurrences.begin(), Occurrences.end());
InitAmbiguousSlot(Occurrences);
//int CountOfAmbigousPlaces = 0;
for (size_t i = 0; i + 1 < Occurrences.size(); ++i)
if (Occurrences[i + 1].first < Occurrences[i].second) {
CPeriodSolutionWeight Solution;
Solution.m_VirtualGroup.SetPair(Occurrences[i].first,Occurrences[i].first);
size_t MaxRightBorder = Occurrences[i].second;
SolveAmbiguityRecursive(Occurrences,i, Solution, MaxRightBorder);
assert (!Solution.m_Solution.empty());
int j=Solution.m_Solution.back() + 1;
for (; j < (int)Occurrences.size(); ++j)
if (Occurrences[j].first >= Occurrences[Solution.m_Solution.back()].second)
break;
Occurrences.erase(Occurrences.begin() + Solution.m_Solution.back() + 1, Occurrences.begin() + j);
for (size_t k=Solution.m_Solution.size() - 1; k > 0; --k) {
size_t start = Solution.m_Solution[k - 1] + 1;
size_t end = Solution.m_Solution[k];
Occurrences.erase(Occurrences.begin() + start, Occurrences.begin() + end);
};
Occurrences.erase(Occurrences.begin() + i, Occurrences.begin() + Solution.m_Solution[0]);
//CountOfAmbigousPlaces++;
};
//printf ("Count Of Ambiguous Places is %i\n",CountOfAmbigousPlaces);;
};