本文整理汇总了C++中yvector::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ yvector::empty方法的具体用法?C++ yvector::empty怎么用?C++ yvector::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yvector
的用法示例。
在下文中一共展示了yvector::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFoundWordsInPeriod
void CMultiWordCreator::GetFoundWordsInPeriod(const SArtPointer& artP, yvector<SWordHomonymNum>& foundWords,
const CWordsPair& wp) const
{
foundWords.clear();
//сначала пытаемся найти среди KwType, которые уже искались на всем предложении, те, которые
//входят в наш отрезок
if (artP.HasKWType()) {
ymap<TKeyWordType, yvector<SWordHomonymNum> >::const_iterator it = m_KW2Words.find(artP.GetKWType());
if (it != m_KW2Words.end()) {
const yvector<SWordHomonymNum>& whs = it->second;
for (size_t i = 0; i < whs.size(); i++) {
CWord& w = m_Words.GetWord(whs[i]);
if (wp.Includes(w.GetSourcePair()))
foundWords.push_back(whs[i]);
}
}
}
if (!foundWords.empty())
return;
//пытаемся найти среди StrType, которые уже искались на всем предложении, те, которые
//входят в наш отрезок
if (artP.HasStrType()) {
ymap<Wtroka, yvector<SWordHomonymNum> >::const_iterator it = m_Title2Words.find(artP.GetStrType());
if (it != m_Title2Words.end()) {
const yvector<SWordHomonymNum>& whs = it->second;
for (size_t i = 0; i < whs.size(); ++i) {
CWord& w = m_Words.GetWord(whs[i]);
if (wp.Includes(w.GetSourcePair()))
foundWords.push_back(whs[i]);
}
}
}
if (!foundWords.empty())
return;
//теперь проходим по запомненным отрезкам, для которых хранятся все найденные MultiWords
ymap<CWordsPair, yvector<SWordHomonymNum> >::const_iterator it = m_FoundWordsByPeriod.find(wp);
if (it != m_FoundWordsByPeriod.end()) {
const yvector<SWordHomonymNum>& whs = it->second;
for (size_t i = 0; i < whs.size(); i++) {
const CHomonym& h = m_Words[whs[i]];
if (h.HasArticle(artP, KW_DICT))
foundWords.push_back(whs[i]);
}
}
}
示例2: Compact
void CGLRTable::Compact(const yvector< yvector<CSLRCell> >& table)
{
Mask.clear();
if (table.empty())
return;
Rows = table.size();
Columns = table[0].size();
YASSERT(Columns != 0);
NGzt::TCompactStorageBuilder<ui32> ruleIndexStorageBuilder;
yvector<ui32> tmp;
Mask.resize((Rows * Columns - 1)/8 + 1);
for (size_t row = 0; row < table.size(); ++row) {
for (size_t column = 0; column < table[row].size(); ++column) {
const CSLRCell& cell = table[row][column];
if (cell.IsEmpty())
continue;
size_t index = row*Columns + column;
Mask[index >> 3] |= 1 << (index & 7);
if (cell.m_ReduceRules.size() == 1 && !cell.m_bShift && cell.m_GotoLine == -1)
// lowest bit 0 means the rest value is already rule index (without encoding in RuleIndexStorage)
//SimpleCells.push_back(MakePair(MakePair(row, column), GetRuleIndex(cell.m_ReduceRules[0]) << 1));
SimpleCells.Add(row, column, GetRuleIndex(cell.m_ReduceRules[0]) << 1);
else {
tmp.clear();
for (size_t i = 0; i < cell.m_ReduceRules.size(); ++i)
tmp.push_back(GetRuleIndex(cell.m_ReduceRules[i]));
ui32 rulesIndex = ruleIndexStorageBuilder.AddRange(tmp.begin(), tmp.end());
// lowest bit 1 means the rest value is already rule index
//SimpleCells.push_back(MakePair(MakePair(row, column), (ComplexCells.size() << 1) + 1)); // overflow check will be done later
SimpleCells.Add(row, column, (ComplexCells.size() << 1) + 1);
ComplexCells.push_back(TCompactSLRCell(cell.m_bShift, cell.m_GotoLine, rulesIndex));
}
}
}
TBufferStream tmpbuf;
ruleIndexStorageBuilder.Save(&tmpbuf);
RuleIndexStorage.Load(&tmpbuf);
// make sure we are not out of index space:
CheckIndexOverflow(ComplexCells.size());
//assert that reverse conversion produces original data
YASSERT(Verify(table));
}