本文整理汇总了C++中Lexicon::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Lexicon::push_back方法的具体用法?C++ Lexicon::push_back怎么用?C++ Lexicon::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexicon
的用法示例。
在下文中一共展示了Lexicon::push_back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Reduce
void CCmpLexicon::Reduce(HStreamBase& inFile)
{
HSwapStream<net_swapper> data(inFile);
lexicon.push_back(LexEntry("\x1b", 0));
RestCharacters chars;
uint32 i;
for (i = 0; i < 256; ++i)
{
chars.push_back(RestChar());
chars[i].ch = static_cast<unsigned char>(i);
chars[i].cnt = 1; // was 0
chars[i].code = 0;
}
uint32 n, h;
// try to reduce the lexicon size to something reasonable
LexiconSet::iterator w;
n = word_set.size();
HAutoBuf<uint32> A_(new uint32[n * 2]);
uint32* A = A_.get();
HAutoBuf<const char*> str(new const char*[n]);
uint32 s = 0;
i = 0;
for (w = word_set.begin(); w != word_set.end(); ++w, ++i)
{
A[i] = i + n;
A[i + n] = (*w).second;
str[i] = (*w).first;
s += strlen(str[i]) + 1;
}
// word_set.clear();
word_set = LexiconSet();
h = n;
make_heap(A, A + h, CntCompare(A));
while (s > max_size)
{
const char* t = str[A[0] - n];
++lexicon.front().cnt;
for (const char* p = t; *p; ++p)
++chars[static_cast<unsigned char>(*p)].cnt;
++chars[0].cnt;
s -= strlen(t) + 1;
A[0] = A[h - 1];
--h;
pop_heap(A, A + h, CntCompare(A));
}
for (i = 0; i < h; ++i)
lexicon.push_back(LexEntry(str[A[i] - n], A[A[i]]));
sort(lexicon.begin() + 1, lexicon.end());
n = lexicon.size();
A = new uint32[n * 2];
for (i = 0; i < n; ++i)
{
A[i] = i + n;
A[i + n] = lexicon[i].cnt;
}
h = n;
make_heap(A, A + h, CntCompare(A));
while (h > 1)
{
uint32 m1 = A[0];
A[0] = A[h - 1];
--h;
pop_heap(A, A + h, CntCompare(A));
uint32 m2 = A[0];
A[0] = A[h - 1];
A[h] = A[m1] + A[m2];
A[0] = h;
A[m1] = A[m2] = h;
pop_heap(A, A + h);
}
A[1] = 0;
for (i = 2; i < 2 * n; ++i)
A[i] = A[A[i]] + 1;
for (i = 0; i < n; ++i)
lexicon[i].cnt = A[i + n];
//.........这里部分代码省略.........