本文整理汇总了C++中StrVec::size方法的典型用法代码示例。如果您正苦于以下问题:C++ StrVec::size方法的具体用法?C++ StrVec::size怎么用?C++ StrVec::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrVec
的用法示例。
在下文中一共展示了StrVec::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trimmedName
string trimmedName(string& s)
{
//printf("splitting %s\n",s.c_str());
StrVec vec;
int n=strsplit_slash(s, vec);
//for(int i=0;i<n;i++) printf(" '%s'\n",vec[i].c_str());
unsigned int i=0;
while(i<vec.size())
{
if(i>0)
{
if(vec[i]==".." && vec[i-1]!="..")
{
i--;
vec.erase(vec.begin()+i,vec.begin()+i+2);
continue;
}
}
i++;
}
if(!vec.size()) return "";
string ret="";
for(unsigned int i=0; i<vec.size(); i++)
{
ret+=vec[i];
if(i+1!=vec.size()) ret+="/";
}
return ret;
}
示例2: prase_package
int Http_Response_Package::prase_package(std::string package)
{
m_line.clear();
m_fields.clear();
StrVec fields;
split_string(package,fields,"\r\n");
if (fields.size()>1)
{
m_line=fields[0];
}
for (unsigned int i=1;i<fields.size(); i++ )
{
int colon_pos=fields[i].find(':');
std::string key=fields[i].substr(0,colon_pos);
std::string value=fields[i].substr(colon_pos+1);
value=trim_string(value," ");
if ( m_fields.find(key)==m_fields.end() )
{
m_fields[key]=value;
}
else
{
m_fields[key]+=";"+value;
}
}
return 0;
}
示例3: main
int main() {
StrVec sv;
print(sv);
sv.push_back("s1"); print(sv);
sv.push_back("s2"); print(sv);
sv.push_back("s3"); print(sv);
sv.push_back("s4"); print(sv);
sv.push_back("s5"); print(sv);
{
StrVec sv2(sv); print(sv2);
sv2.push_back("s6"); print(sv); print(sv2);
sv.pop_back(); print(sv); print(sv2);
sv = sv2; print(sv); print(sv2);
}
sv.reserve(sv.capacity() / 2); print(sv);
sv.reserve(sv.capacity() * 2); print(sv);
sv.resize(sv.size() + 2); print(sv);
sv.resize(sv.size() + 2, "s7"); print(sv);
sv.resize(sv.size() - 2); print(sv);
sv.resize(sv.size() - 2, "s7"); print(sv);
return 0;
}
示例4: breakDir
void cGRASS::breakDir(string Dir)
{
StrVec Vec;
Vec.clear();
char dir[255];
strcpy(dir,Dir.c_str());
char * t;
string temp;
printf ("Splitting string \"%s\" into tokens:\n",dir);
t = strtok (dir,"/");
while (t != NULL)
{
temp = t;
Vec.push_back(temp);
t = strtok (NULL, "/");
}
MapSet = Vec[Vec.size()-1];
Location = Vec[Vec.size()-2];
GDBase = "";
for (uint i = 0; i < Vec.size()-2; i++)
{
GDBase = GDBase + "/" + Vec[i];
}
// printf(MapSet);
// printf(Location);
// printf(GDBase);
}
示例5: exec
void Console::exec(std::string cmd)
{
StrVec args;
if(cmd.find(' ') != std::string::npos)
{
args.push_back(cmd.substr(cmd.find(' ') + 1, cmd.size() - cmd.find(' ')));
cmd = cmd.substr(0, cmd.find(' '));
while(args.back().find(' ') != std::string::npos)
{
args.push_back(args.back().substr(args.back().find(' ') + 1 , args.size() - args.back().find(' ')));
args.at(args.size() - 1) = args.at(args.size() - 1).substr(0, args.at(args.size() - 1).find(' ') - 1);
}
}
if(commands.find(cmd) == commands.end())
{
addString("Command '" + cmd + "' not found");
return;
}
if(!commands[cmd].exec(args)) addString("Wrong number of arguments for command '" + cmd + "'.");
}
示例6:
bool operator>=(const StrVec &lhs, const StrVec &rhs)
{
auto sz = lhs.size() < rhs.size() ? lhs.size() : rhs.size();
auto pl = lhs.begin(), pr = rhs.begin();
while (sz-- && *pl == *pr)
++pl, ++pr;
return sz ? *pl >= *pr : pr == rhs.end();
}
示例7:
bool operator==(const StrVec &lhs, const StrVec &rhs)
{
if (lhs.size() != rhs.size())
return false;
for (auto pl = lhs.begin(), pr = rhs.begin(); pl != lhs.end(); )
if (*pl != *pr)
return false;
return true;
}
示例8: match
bool match(const PackInfo &other) const
{
if(other.dirs.size() != dirs.size()) return false;
assert(dirs.size() == paths.size());
assert(dirs.size() == other.paths.size());
for(int i=0; i<dirs.size(); i++)
if(dirs[i] != other.dirs[i] || paths[i] != other.paths[i])
return false;
return true;
}
示例9: if
bool operator< (const StrVec & s1,const StrVec &s2)
{
for(size_t i =0 ; i< s1.size() && i < s2.size(); i++)
{
if(*(s1.elements+i ) < *(s2.elements+i) )
return true ;
else if(*(s1.elements+i ) < *(s2.elements+i) )
return false;
}
if(s1.size() < s2.size())
return true ;
return false;
}
示例10:
bool operator==(const StrVec &s1 ,const StrVec &s2)
{
if(s1.size() == s2.size())
{
for(size_t i =0 ; i< s1.size() ; i++)
{
if(*(s1.elements+i ) != *(s2.elements+i) )
return false ;
}
return true;
}
return false ;
}
示例11:
bool operator==(const StrVec& lhs, const StrVec& rhs)
{
if(lhs.size() != rhs.size())
{
return false;
}
for(auto itrL=lhs.begin(), itrR=rhs.begin(); itrL!=lhs.end(), itrR!=rhs.end(); itrL++, itrR++)
{
if(itrL != itrR)
{
return false;
}
}
return true;
}
示例12: main
int main() {
StrVec words;
words.push_back("ss");
words.push_back("sb");
words.push_back("asf");
words.push_back("safasfd");
words.push_back("asfas");
std::cout<<words.size()<<std::endl;
//words = StrVec();
//words = words;
std::cout<<"cap "<<words.capacity()<<std::endl;
std::cout<<"sz "<<words.size()<<std::endl;
for_each(words.begin(), words.end(), [](const std::string &s){std::cout<<s<<std::endl;});
std::cout<<"exit"<<std::endl;
}
示例13: getORBOptions
void CorbaNotifyUtils::getORBOptions(const std::string &appName,const std::string &orbOptions,
int &orbArgc,ACE_TCHAR*** orbArgv)
{
StrVec ORBOptionsVec;
size_t ini = orbOptions.find_first_not_of(" \t");
size_t end;
while(ini != std::string::npos)
{
end = orbOptions.find_first_of(" \t", ini + 1);
if(end != std::string::npos)
{
ORBOptionsVec.push_back(orbOptions.substr(ini, end - ini));
ini = orbOptions.find_first_not_of(" \t", end);
} else {
ORBOptionsVec.push_back(orbOptions.substr(ini));
ini = std::string::npos;
}
}
int i = 1;
orbArgc = ORBOptionsVec.size() + 1;
*orbArgv = new ACE_TCHAR*[orbArgc];
(*orbArgv)[0] = new ACE_TCHAR[appName.size() + 1];
strncpy((*orbArgv)[0], appName.c_str(), appName.size());
(*orbArgv)[0][appName.size()] = '\0';
for(StrVec::const_iterator it = ORBOptionsVec.begin();
it != ORBOptionsVec.end(); ++it, ++i)
{
(*orbArgv)[i] = new ACE_TCHAR[it->size() + 1];
strncpy((*orbArgv)[i], it->c_str(), it->size());
(*orbArgv)[i][it->size()] = '\0';
ACE_DEBUG((LM_INFO, "%T ORB option: %s\n", (*orbArgv)[i]));
}
}
示例14: main
int main(int argc, char *argv[])
{
argc--, argv++;
if (argc == 0) {
fprintf(stderr, "mecab_smpl filename\n");
return 1;
}
try {
const std::string fileName = argv[0];
cybozu::Mmap mmap(fileName);
if (mmap.size() > (1 << 30)) {
fprintf(stderr, "file is too large %lld\n", (long long)mmap.size());
return 1;
}
cybozu::nlp::Mecab mecab;
typedef std::vector<std::string> StrVec;
StrVec sv;
if (mecab.parse(sv, mmap.get(), (int)mmap.size())) {
for (size_t i = 0, n = sv.size(); i < n; i++) {
printf("%s ", sv[i].c_str());
}
printf("\n");
}
return 0;
} catch (std::exception& e) {
fprintf(stderr, "exception %s\n", e.what());
} catch (...) {
fprintf(stderr, "unknown exception\n");
}
return 1;
}
示例15: print
void print(const StrVec &sv) {
std::cout << "<" << &sv << "> size: " << sv.size()
<< " capacity: " << sv.capacity() << " contents:";
for (const auto &s : sv)
std::cout << " <" << s << ">";
std::cout << std::endl;
}