本文整理汇总了C++中Bits::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Bits::set方法的具体用法?C++ Bits::set怎么用?C++ Bits::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bits
的用法示例。
在下文中一共展示了Bits::set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
gen_admissible()
{
unsigned n = 2;
while (n < NMAX)
{
b1.set(n);
n *= 2;
}
overall |= b1;
for (int i = 0; i < num_primes; i++)
{
uint64 p = primes[i];
do
{
size_t pos = b1.find_first();
uint64 j;
while (pos != string::npos && (j = pos * p) < NMAX)
{
//cout << j << endl;
b2.set(j);
pos = b1.find_next(pos);
}
p *= primes[i];
} while (p < NMAX);
overall |= b2;
b1.clear();
b1.resize(NMAX + 1);
b1.swap(b2);
}
}
示例2:
void
Ticket_ATTLC::Validate(Bits& b)
{
unsigned int count = 0;
while (b[count])
count++;
while (count >= b.size())
b.size(b.size() + bits_increment);
num = count;
b.set(num);
}
示例3: generateSummary
static void generateSummary( Summary &summary, char *htmlInput, const char *queryStr, const char *urlStr ) {
Xml xml;
ASSERT_TRUE(xml.set(htmlInput, strlen(htmlInput), 0, CT_HTML));
Words words;
ASSERT_TRUE(words.set(&xml, true));
Bits bits;
ASSERT_TRUE(bits.set(&words));
Url url;
url.set(urlStr);
Sections sections;
ASSERT_TRUE(sections.set(&words, &bits, &url, "", CT_HTML));
Query query;
ASSERT_TRUE(query.set2(queryStr, langEnglish, true));
LinkInfo linkInfo;
memset ( &linkInfo , 0 , sizeof(LinkInfo) );
linkInfo.m_lisize = sizeof(LinkInfo);
Title title;
ASSERT_TRUE(title.setTitle(&xml, &words, 80, &query, &linkInfo, &url, NULL, 0, CT_HTML, langEnglish));
Pos pos;
ASSERT_TRUE(pos.set(&words));
Bits bitsForSummary;
ASSERT_TRUE(bitsForSummary.setForSummary(&words));
Phrases phrases;
ASSERT_TRUE(phrases.set(&words, &bits));
Matches matches;
matches.setQuery(&query);
ASSERT_TRUE(matches.set(&words, &phrases, §ions, &bitsForSummary, &pos, &xml, &title, &url, &linkInfo));
summary.setSummary(&xml, &words, §ions, &pos, &query, 180, 3, 3, 180, &url, &matches, title.getTitle(), title.getTitleLen());
}
示例4: assert
dt_t *ArrayInitializer::toDtBit()
{
#if DMDV1
unsigned size;
unsigned length;
unsigned tadim;
dt_t *d;
dt_t **pdtend;
Type *tb = type->toBasetype();
//printf("ArrayInitializer::toDtBit('%s')\n", toChars());
Bits databits;
Bits initbits;
if (tb->ty == Tsarray)
{
/* The 'dim' for ArrayInitializer is only the maximum dimension
* seen in the initializer, not the type. So, for static arrays,
* use instead the dimension of the type in order
* to get the whole thing.
*/
dinteger_t value = ((TypeSArray*)tb)->dim->toInteger();
tadim = value;
assert(tadim == value); // truncation overflow should already be checked
databits.resize(tadim);
initbits.resize(tadim);
}
else
{
databits.resize(dim);
initbits.resize(dim);
}
/* The default initializer may be something other than zero.
*/
if (tb->next->defaultInit()->toInteger())
databits.set();
size = sizeof(databits.data[0]);
length = 0;
for (size_t i = 0; i < index.dim; i++)
{ Expression *idx;
Initializer *val;
Expression *eval;
idx = (Expression *)index.data[i];
if (idx)
{ dinteger_t value;
value = idx->toInteger();
length = value;
if (length != value)
{ error(loc, "index overflow %llu", value);
length = 0;
}
}
assert(length < dim);
val = (Initializer *)value.data[i];
eval = val->toExpression();
if (initbits.test(length))
error(loc, "duplicate initializations for index %d", length);
initbits.set(length);
if (eval->toInteger()) // any non-zero value is boolean 'true'
databits.set(length);
else
databits.clear(length); // boolean 'false'
length++;
}
d = NULL;
#ifdef IN_GCC
pdtend = dtnbits(&d, databits.allocdim * size, (char *)databits.data, sizeof(databits.data[0]));
#else
pdtend = dtnbytes(&d, databits.allocdim * size, (char *)databits.data);
#endif
switch (tb->ty)
{
case Tsarray:
{
if (dim > tadim)
{
error(loc, "too many initializers, %d, for array[%d]", dim, tadim);
}
else
{
tadim = (tadim + 31) / 32;
if (databits.allocdim < tadim)
pdtend = dtnzeros(pdtend, size * (tadim - databits.allocdim)); // pad out end of array
}
break;
}
case Tpointer:
case Tarray:
// Create symbol, and then refer to it
Symbol *s;
s = static_sym();
s->Sdt = d;
//.........这里部分代码省略.........
示例5: set
// . return length stored into "buf"
// . content must be NULL terminated
// . if "useAnchors" is true we do click and scroll
// . if "isQueryTerms" is true, we do typical anchors in a special way
int32_t Highlight::set ( SafeBuf *sb,
//char *buf ,
//int32_t bufLen ,
char *content ,
int32_t contentLen ,
// primary language of the document (for synonyms)
char docLangId ,
Query *q ,
bool doStemming ,
bool useAnchors ,
const char *baseUrl ,
const char *frontTag ,
const char *backTag ,
int32_t fieldCode ,
int32_t niceness ) {
Words words;
if ( ! words.set ( content ,
contentLen ,
TITLEREC_CURRENT_VERSION,
true , // computeId
true ) ) // has html entites?
return -1;
int32_t version = TITLEREC_CURRENT_VERSION;
Bits bits;
if ( ! bits.set (&words,version,niceness) ) return -1;
Phrases phrases;
if ( !phrases.set(&words,&bits,true,false,version,niceness))return -1;
//SafeBuf langBuf;
//if ( !setLangVec ( &words , &langBuf , niceness )) return 0;
//uint8_t *langVec = (uint8_t *)langBuf.getBufStart();
// make synonyms
//Synonyms syns;
//if(!syns.set(&words,NULL,docLangId,&phrases,niceness,NULL)) return 0;
Matches matches;
matches.setQuery ( q );
if ( ! matches.addMatches ( &words , &phrases ) ) return -1;
// store
m_numMatches = matches.getNumMatches();
return set ( sb ,
//buf ,
//bufLen ,
&words ,
&matches ,
doStemming ,
useAnchors ,
baseUrl ,
frontTag ,
backTag ,
fieldCode ,
q );
}