本文整理汇总了C++中StringSet::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ StringSet::clear方法的具体用法?C++ StringSet::clear怎么用?C++ StringSet::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSet
的用法示例。
在下文中一共展示了StringSet::clear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Clear
void Clear()
{
if (NULL != txn)
{
mdb_txn_abort(txn);
txn = NULL;
}
ref = 0;
dels.clear();
inserts.clear();
}
示例2: loggerNames
MojErr MojLogEngine::loggerNames(StringSet& setOut)
{
setOut.clear();
MojThreadGuard guard(m_mutex);
for (LoggerList::ConstIterator i = m_loggers.begin(); i != m_loggers.end(); ++i) {
MojString name;
MojErr err = name.assign((*i)->name());
MojErrCheck(err);
err = setOut.put(name);
MojErrCheck(err);
}
return MojErrNone;
}
示例3: GetAllLemmasWhosePathesStartFromThisSequence
void CDwdsThesaurus::GetAllLemmasWhosePathesStartFromThisSequence (const vector<int>& HyperTermNos, StringSet& Lemmas) const
{
DwordVector Result;
GetAllPathesWhichStartFromThisSequence(HyperTermNos, Result);
sort(Result.begin(),Result.end());
Lemmas.clear();
for (size_t i=0; i<LeavesPathes.size(); i++)
if (binary_search(Result.begin(),Result.end(), LeavesPathes[i]))
{
const char* s = LeavesLemmas[i].GetString();
Lemmas.insert(s);
};
};
示例4: main
////////////////////////////////////////////////////////////////////////////////
// TODO: Duplicate code with reducer-shingle-threshold.cpp. Refactor into class
// with virtual method call to call the emit method
int main() {
char value[1000], key[1000];
StringSet shingleSet;
std::string prevKey;
while (scanf("%s\t%s\n", key, value) != EOF) {
if (prevKey != key) {
emitShinglesWithDocSizes(shingleSet, prevKey);
shingleSet.clear();
}
shingleSet.insert(value);
prevKey = key;
}
emitShinglesWithDocSizes(shingleSet, prevKey);
return 0;
}
示例5: count
/**
* categories is the selected categories for one image, members may be Las Vegas, Chicago, and Los Angeles if the
* category in question is Places.
* This function then increases _groupCount with 1 for each of the groups the relavant items belongs to
* Las Vegas might increase the _groupCount[Nevada] by one.
* The tricky part is to avoid increasing it by more than 1 per image, that is what the countedGroupDict is
* used for.
*/
void GroupCounter::count( const StringSet& categories )
{
static StringSet countedGroupDict;
countedGroupDict.clear();
for( StringSet::const_iterator categoryIt = categories.begin(); categoryIt != categories.end(); ++categoryIt ) {
if ( _memberToGroup.contains(*categoryIt)) {
const QStringList groups = _memberToGroup[*categoryIt];
for ( const QString& group : groups ) {
if ( !countedGroupDict.contains( group ) ) {
countedGroupDict.insert( group );
(_groupCount[group])++;
}
}
}
// The item Nevada should itself go into the group Nevada.
if ( !countedGroupDict.contains( *categoryIt ) && _groupCount.contains( *categoryIt ) ) {
countedGroupDict.insert( *categoryIt);
(_groupCount[*categoryIt])++;
}
}
}
示例6: main
//.........这里部分代码省略.........
}
ScanFile(argv[i], ext, false, verbose);
}
/* Default output file is Makefile */
if (filename == NULL) filename = strdup("Makefile");
/* Default delimiter string */
if (delimiter == NULL) delimiter = strdup("# DO NOT DELETE");
char backup[PATH_MAX];
strcpy(backup, filename);
strcat(backup, ".bak");
char *content = NULL;
long size = 0;
/* Read in the current file; so we can overwrite everything from the
* end of non-depend data marker down till the end. */
FILE *src = fopen(filename, "rb");
if (src != NULL) {
fseek(src, 0, SEEK_END);
size = ftell(src);
rewind(src);
content = (char*)malloc(size * sizeof(*content));
if (fread(content, 1, size, src) != (size_t)size) {
fprintf(stderr, "Could not read %s\n", filename);
exit(-2);
}
fclose(src);
}
FILE *dst = fopen(filename, "w");
bool found_delimiter = false;
if (size != 0) {
src = fopen(backup, "wb");
if (fwrite(content, 1, size, src) != (size_t)size) {
fprintf(stderr, "Could not write %s\n", filename);
exit(-2);
}
fclose(src);
/* Then append it to the real file. */
src = fopen(backup, "rb");
while (fgets(content, size, src) != NULL) {
fputs(content, dst);
if (!strncmp(content, delimiter, strlen(delimiter))) found_delimiter = true;
if (!append && found_delimiter) break;
}
fclose(src);
}
if (!found_delimiter) fprintf(dst, "\n%s\n", delimiter);
for (StringMap::iterator it = _files.begin(); it != _files.end(); it++) {
for (StringSet::iterator h = it->second->begin(); h != it->second->end(); h++) {
fprintf(dst, "%s: %s\n", it->first, *h);
}
}
/* Clean up our mess. */
fclose(dst);
free(delimiter);
free(filename);
free(ext);
free(content);
for (StringMap::iterator it = _files.begin(); it != _files.end(); it++) {
for (StringSet::iterator h = it->second->begin(); h != it->second->end(); h++) {
free(*h);
}
it->second->clear();
delete it->second;
free(it->first);
}
_files.clear();
for (StringMap::iterator it = _headers.begin(); it != _headers.end(); it++) {
for (StringSet::iterator h = it->second->begin(); h != it->second->end(); h++) {
free(*h);
}
it->second->clear();
delete it->second;
free(it->first);
}
_headers.clear();
for (StringSet::iterator it = _defines.begin(); it != _defines.end(); it++) {
free(*it);
}
_defines.clear();
for (StringSet::iterator it = _include_dirs.begin(); it != _include_dirs.end(); it++) {
free(*it);
}
_include_dirs.clear();
return 0;
}
示例7: ScanFile
//.........这里部分代码省略.........
lexer.Lex();
if (!ignore.empty()) ignore.pop();
if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
break;
case TOKEN_ELSE: {
if (verbose) fprintf(stderr, "%s #else", filename);
lexer.Lex();
Ignore last = ignore.empty() ? NOT_IGNORE : ignore.top();
if (!ignore.empty()) ignore.pop();
if (ignore.empty() || ignore.top() == NOT_IGNORE) {
ignore.push(last == IGNORE_UNTIL_ELSE ? NOT_IGNORE : IGNORE_UNTIL_ENDIF);
} else {
ignore.push(IGNORE_UNTIL_ENDIF);
}
if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
break;
}
case TOKEN_ELIF: {
if (verbose) fprintf(stderr, "%s #elif ", filename);
lexer.Lex();
Ignore last = ignore.empty() ? NOT_IGNORE : ignore.top();
if (!ignore.empty()) ignore.pop();
if (ignore.empty() || ignore.top() == NOT_IGNORE) {
bool value = ExpressionOr(&lexer, &defines, verbose);
ignore.push(last == IGNORE_UNTIL_ELSE ? (value ? NOT_IGNORE : IGNORE_UNTIL_ELSE) : IGNORE_UNTIL_ENDIF);
} else {
ignore.push(IGNORE_UNTIL_ENDIF);
}
if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
break;
}
case TOKEN_IF: {
if (verbose) fprintf(stderr, "%s #if ", filename);
lexer.Lex();
if (ignore.empty() || ignore.top() == NOT_IGNORE) {
bool value = ExpressionOr(&lexer, &defines, verbose);
ignore.push(value ? NOT_IGNORE : IGNORE_UNTIL_ELSE);
} else {
ignore.push(IGNORE_UNTIL_ENDIF);
}
if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
break;
}
case TOKEN_IFDEF:
if (verbose) fprintf(stderr, "%s #ifdef ", filename);
lexer.Lex();
if (lexer.GetToken() == TOKEN_IDENTIFIER) {
bool value = defines.find(lexer.GetString()) != defines.end();
if (verbose) fprintf(stderr, "%s[%d]", lexer.GetString(), value);
if (ignore.empty() || ignore.top() == NOT_IGNORE) {
ignore.push(value ? NOT_IGNORE : IGNORE_UNTIL_ELSE);
} else {
ignore.push(IGNORE_UNTIL_ENDIF);
}
}
if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
break;
case TOKEN_IFNDEF:
if (verbose) fprintf(stderr, "%s #ifndef ", filename);
lexer.Lex();
if (lexer.GetToken() == TOKEN_IDENTIFIER) {
bool value = defines.find(lexer.GetString()) != defines.end();
if (verbose) fprintf(stderr, "%s[%d]", lexer.GetString(), value);
if (ignore.empty() || ignore.top() == NOT_IGNORE) {
ignore.push(!value ? NOT_IGNORE : IGNORE_UNTIL_ELSE);
} else {
ignore.push(IGNORE_UNTIL_ENDIF);
}
}
if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
break;
default:
if (verbose) fprintf(stderr, "%s #<unknown>", filename);
lexer.Lex();
break;
}
if (verbose) fprintf(stderr, "\n");
/* FALL THROUGH */
default:
/* Ignore the rest of the garbage on this line */
while (lexer.GetToken() != TOKEN_EOL && lexer.GetToken() != TOKEN_END) lexer.Lex();
lexer.Lex();
break;
}
}
if (!header) {
for (StringSet::iterator it = defines.begin(); it != defines.end(); it++) {
free(*it);
}
defines.clear();
while (!ignore.empty()) ignore.pop();
}
}