本文整理汇总了C++中StringSet类的典型用法代码示例。如果您正苦于以下问题:C++ StringSet类的具体用法?C++ StringSet怎么用?C++ StringSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(StringSetTest, IntersectionOfTwoStrings) {
// Tests the intersection of two set, including only strings occuring
// in both sets.
StringSet first, second;
first.Add("First string.");
first.Add("Second string.");
first.Add("Third string.");
second.Add("First string.");
second.Add("Second string.");
StringSet intersection = first.Intersection(second);
EXPECT_TRUE(intersection.Contains("First string."));
EXPECT_TRUE(intersection.Contains("Second string."));
EXPECT_FALSE(intersection.Contains("Third string."));
EXPECT_EQ(2, intersection.Count());
}
示例2: getAllSymbolsUsedByThisKernel
static StringVector getAllSymbolsUsedByThisKernel(
const std::string& kernelName, ir::Module* module)
{
auto kernel = module->kernels().find(kernelName);
if(kernel == module->kernels().end()) return StringVector();
StringSet encountered;
for(auto block = kernel->second->cfg()->begin();
block != kernel->second->cfg()->end(); ++block)
{
for(auto instruction = block->instructions.begin();
instruction != block->instructions.end(); ++instruction)
{
typedef std::vector<ir::PTXOperand*> OperandVector;
auto ptx = static_cast<ir::PTXInstruction*>(*instruction);
OperandVector operands;
operands.push_back(&ptx->a);
operands.push_back(&ptx->b);
operands.push_back(&ptx->pg);
operands.push_back(&ptx->pq);
operands.push_back(&ptx->d);
if(ptx->opcode != ir::PTXInstruction::Call)
{
operands.push_back(&ptx->c);
}
for(auto operand = operands.begin();
operand != operands.end(); ++operand)
{
if((*operand)->addressMode != ir::PTXOperand::Address &&
(*operand)->addressMode != ir::PTXOperand::FunctionName)
{
continue;
}
encountered.insert((*operand)->identifier);
}
}
}
return StringVector(encountered.begin(), encountered.end());
}
示例3: gen_taxrules
// Generate Transactions and Taxonomy
//
void gen_taxrules(TaxPar &par)
{
Taxonomy *tax;
StringSet *lits;
StringSetIter *patterns;
Transaction *trans;
poisson_distribution<LINT> tlen(par.tlen - 1);
ofstream data_fp;
ofstream pat_fp;
ofstream tax_fp;
data_fp.open(data_file, ios::trunc);
pat_fp.open(pat_file, ios::trunc);
tax_fp.open(tax_file, ios::trunc);
if (data_fp.fail() || pat_fp.fail() || tax_fp.fail()) {
cerr << "Error opening output file" << endl;
exit(1);
}
// generate taxonomy and write it to file
tax = new Taxonomy(par.nitems, par.nroots, par.fanout, par.depth_ratio);
if (par.ascii)
tax->write_asc(tax_fp);
else
tax->write(tax_fp);
lits = new StringSet(par.nitems, par.lits, tax);
par.write(pat_fp);
lits->display(pat_fp);
patterns = new StringSetIter(*lits);
for (LINT i = 0; i < par.ntrans; i ++)
{
trans = mk_tran(*patterns, tlen(generator) + 1, tax);
if (par.ascii)
trans->write_asc(data_fp);
else
trans->write(data_fp);
delete trans;
delete trans;
}
data_fp.close();
pat_fp.close();
tax_fp.close();
}
示例4: ValidateCheckPrefixes
static bool ValidateCheckPrefixes() {
StringSet<> PrefixSet;
for (prefix_iterator I = CheckPrefixes.begin(), E = CheckPrefixes.end();
I != E; ++I) {
StringRef Prefix(*I);
if (!PrefixSet.insert(Prefix))
return false;
if (!ValidateCheckPrefix(Prefix))
return false;
}
return true;
}
示例5: 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;
}
示例6: queueTargets
void SBWorkspace::queueTargets(const StringSet& targetNames, const StringSet& configNames) {
BuildSettings bs(NULL);
bool isInteractive = bs.getValue("VSIMPORTER_INTERACTIVE") == "YES";
// Get the specified targets
PotentialTargetsVec selectedTargets;
if (isInteractive) {
// Query the user to select targets to be queued
selectTargets(selectedTargets);
} else if (targetNames.empty()) {
// Queue up all targets
getAllTargets(selectedTargets);
} else {
// Try to find matching targets by name
for (auto targetName : targetNames) {
TargetProjectPair targetKV = findTargetWithName(targetName);
if (targetKV.first) {
selectedTargets.push_back(targetKV);
}
}
}
// Queue targets
for (auto targetKV : selectedTargets) {
SBTarget* target = targetKV.second->queueTarget(targetKV.first, &configNames);
// Mark target as having been explicitly queued up
if (target) {
target->markExplicit();
}
}
}
示例7: split
//字符串拆分
void split(const string& in, const string delimiter, StringSet& out)
{
string::size_type cur = 0;
string::size_type next = 0;
next = in.find(delimiter, cur);
while(next != std::string::npos)
{
out.insert(in.substr(cur, next - cur));
cur = next + 1;
next = in.find(delimiter, cur);
}
out.insert(in.substr(cur));
}
示例8: writeProjectItem
static void writeProjectItem(const ProjectItem* item, const StringMap& params, const StringSet& urlSchemes)
{
if (!item)
return;
// Open input file
auto inMode = item->replaceParams ? ios::in : ios::binary;
ifstream ifs(item->inFile.c_str(), inMode);
if (!ifs.is_open()) {
SBLog::warning() << "Failed to open " << item->inFile << " for reading." << std::endl;
return;
}
// Open output file
ofstream ofs;
auto outMode = item->replaceParams ? ios::out : ios::binary;
openOutputFileStream(ofs, item->outFile, outMode);
if (item->replaceParams) {
// Expand input line by line and write it out
std::string line;
while (std::getline(ifs, line)) {
expandString(line, params);
ofs << line << std::endl;
}
} else {
// Copy the file contents
ofs << ifs.rdbuf();
}
if (!urlSchemes.empty() && isAppxManifestFileName(item->inFile)) {
ofs.close();
insertUrlSchemes(item->outFile, urlSchemes);
}
}
示例9: write_stringset
bool write_stringset(SerialOut &out, const StringSet &list) {
auto len = static_cast<uint32_t>(list.size());
out.out_.Write((const char*)&len, sizeof(len));
for (auto &s : list)
out <= s;
return out.out_;
}
示例10: processItemPair
void processItemPair(StringSet & as, ConfigListBuilder & lb, substring src, substring dst) {
item_analysis a_src = analyzeItem(src);
item_analysis a_dst = analyzeItem(dst);
as.insert(a_src.item_name);
as.insert(a_dst.item_name);
generateLinkSection(lb, a_src.item_name, a_dst.item_name, a_src.right_properties.merge(a_dst.left_properties));
}
示例11:
void Exif::TreeView::setSelectedExif( const StringSet& selected )
{
for ( QTreeWidgetItemIterator it( this ); *it; ++it ) {
bool on = selected.contains( (*it)->text(1) );
(*it)->setCheckState(0,on ? Qt::Checked : Qt::Unchecked );
}
}
示例12: MojAssertMutexLocked
MojErr MojDbKindState::initTokens(MojDbReq& req, const StringSet& strings)
{
MojAssertMutexLocked(m_lock);
// load tokens
MojErr err = readObj(TokensKey, m_tokensObj, m_kindEngine->kindDb(), req.txn(), m_oldTokensItem);
MojErrCheck(err);
// populate token vec
MojUInt8 maxToken = 0;
err = m_tokenVec.resize(m_tokensObj.size());
MojErrCheck(err);
for (MojObject::ConstIterator i = m_tokensObj.begin(); i != m_tokensObj.end(); ++i) {
MojString key = i.key();
MojInt64 value = i.value().intValue();
MojSize idx = (MojSize) (value - MojObjectWriter::TokenStartMarker);
if (value < MojObjectWriter::TokenStartMarker || value >= MojUInt8Max || idx >= m_tokenVec.size()) {
MojErrThrow(MojErrDbInvalidToken);
}
if (value > maxToken) {
maxToken = (MojUInt8) value;
}
err = m_tokenVec.setAt(idx, key);
MojErrCheck(err);
}
if (maxToken > 0) {
m_nextToken = (MojUInt8) (maxToken + 1);
}
// add strings
bool updated = false;
for (StringSet::ConstIterator i = strings.begin(); i != strings.end(); ++i) {
if (!m_tokensObj.contains(*i)) {
updated = true;
MojUInt8 token = 0;
TokenVec tokenVec;
MojObject tokenObj;
err = addPropImpl(*i, false, token, tokenVec, tokenObj);
MojErrCheck(err);
}
}
if (updated) {
err = writeTokens(m_tokensObj);
MojErrCheck(err);
}
return MojErrNone;
}
示例13: foundIn
int StringSet::foundIn(const StringSet ss) const{
int count = 0;
for (size_t i = 0; i < this->size(); ++i){
if(ss.duplicate(this->at(i)))
count++;
}
return count;
}
示例14: 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;
}
示例15: Put
void Put(const Slice& key, const Slice& value)
{
std::string str(key.data(), key.size());
std::string v(value.data(), value.size());
dels.erase(str);
inserts[str] = v;
}