本文整理汇总了C++中StringSet::get_pat方法的典型用法代码示例。如果您正苦于以下问题:C++ StringSet::get_pat方法的具体用法?C++ StringSet::get_pat怎么用?C++ StringSet::get_pat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSet
的用法示例。
在下文中一共展示了StringSet::get_pat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
void String::display(ofstream &fp, StringSet &lits, LINT prob_comp)
{
LINT i, j;
StringP lstr;
int flag = 0;
fp << setw(6) << prob_comp * prob << " " << setw(6) << conf << " ";
for(i = 0; i < nitems; i++)
{
fp << "(";
lstr = lits.get_pat(items[i]);
for (j = 0; j < lstr->nitems; j++)
{
if ( flag == 0 )
{
fp << lstr->items[j];
flag = 1;
}
else
fp << "," << lstr->items[j];
}
flag = 0;
fp << ")";
}
fp << endl;
return;
}
示例2: display
void String::display(ofstream &fp, StringSet &lits, LINT prob_comp)
{
LINT i, j;
StringP lstr;
fp << setw(6) << prob_comp * prob << " " << setw(6) << conf << " ";
for (i = 0; i < nitems; i++)
{
fp << " << ";
lstr = lits.get_pat(items[i]);
for (j = 0; j < lstr->nitems; j++)
fp << lstr->items[j] << " ";
fp << ">>";
}
fp << endl;
return;
}
示例3: add
// adds pattern to CustSeq
// returns TRUE if pattern was added, FALSE else
// REWORK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
BOOLEAN CustSeq::add(String &pat, StringSet &lits)
{
static UniformDist ud;
LINT i, patlen;
LINT pos;
LINT newitems, olditems;
BOOLEAN corrupt; // if TRUE, corrupt transactions too
if ( ud() > pat.conf_lvl() )
corrupt = TRUE; // corrupt transactions
else
corrupt = FALSE; // don't corrupt transactions
// corrupt the pattern by reducing its length;
// conf_lvl for a pattern is decided at the time of pattern creation
patlen = pat.size();
if ( corrupt )
while ( patlen > 0 && ud() > pat.conf_lvl() )
patlen--;
if ( patlen == 0 ) // no trans. left in sequence
return TRUE;
// allows transactions to be dropped randomly from the sequence
// if ( patlen < pat.size() )
Choose shuffle(pat.size(), patlen);
// pat.shuffle(patlen);
// calculate # of items in pattern
for (newitems = 0, i = 0; i < patlen; i++)
newitems += lits.get_pat( pat.item( shuffle.pos(i) ) )->size();
// newitems += lits.get_pat( pat.rand_item(i) )->size();
// in half of the cases, we drop the pattern that won't fit
if ( (patlen > slen) || (newitems + nitems > slen * tlen) )
if ( ud() > 0.5 )
return FALSE;
if ( patlen > maxsize ) { // need to allocate more memory
TransactionP *old_trans = trans;
LINT oldsize = maxsize;
maxsize = patlen*2;
trans = new TransactionP [maxsize];
for (i = 0; i < oldsize; i++)
trans[i] = old_trans[i];
for (; i < maxsize; i++)
trans[i] = NULL;
delete [] old_trans;
}
// add new sequence
Choose *shuffle1 = NULL;
if (ntrans > patlen)
shuffle1 = new Choose(ntrans, patlen);
for (i = 0; i < patlen; i++)
{
if ( shuffle1 )
pos = shuffle1->pos(i);
else
pos = i;
if ( trans[pos] == NULL )
trans[pos] = new Transaction(tlen);
olditems = trans[pos]->size();
trans[pos]->add( *lits.get_pat(pat.item( shuffle.pos(i) )), corrupt );
// trans[pos]->add( *lits.get_pat(pat.rand_item(i)), corrupt );
nitems += trans[pos]->size() - olditems; // update count of #items
}
delete shuffle1;
// pos = ud() * ntrans / patlen;
// for (i = 0; i < patlen; i++)
// {
// if ( trans[pos] == NULL )
// trans[pos] = new Transaction(tlen);
// olditems = trans[pos]->size();
// trans[pos]->add( *lits.get_pat(pat.item( shuffle.pos(i) )), corrupt );
// // trans[pos]->add( *lits.get_pat(pat.rand_item(i)), corrupt );
// nitems += trans[pos]->size() - olditems; // update count of #items
// pos += 1 + ud() * ntrans / patlen;
// }
return TRUE;
}