本文整理汇总了C++中StrVec::end方法的典型用法代码示例。如果您正苦于以下问题:C++ StrVec::end方法的具体用法?C++ StrVec::end怎么用?C++ StrVec::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrVec
的用法示例。
在下文中一共展示了StrVec::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_lists
StrVec read_lists (const StrVec& fnames)
{
StrVec rv;
StrVec::const_iterator itr = fnames.begin ();
while (itr != fnames.end ())
{
StrVec vals = read_list (*itr);
std::copy (vals.begin (), vals.end (), std::back_inserter (rv));
itr ++;
}
return rv;
}
示例2: desiresCB
void EventsGenerator::desiresCB(const hbba_msgs::DesiresSet::ConstPtr& msg)
{
typedef std::vector<std::string> StrVec;
typedef std::list<std::string> StrList;
typedef std::vector<hbba_msgs::Desire> DesVec;
typedef std::map<std::string,std::string> TypeMap;
const DesVec& desires = msg->desires;
TypeMap typeMap;
StrVec ids;
ids.reserve(desires.size());
for (DesVec::const_iterator d = desires.begin(); d != desires.end(); ++d)
{
ids.push_back(d->id);
typeMap[d->id] = d->type;
}
// First, remove desires not in it the current desires set.
StrList del;
for (Model::const_iterator i = model_.begin(); i != model_.end(); ++i)
{
const std::string& id = i->first;
if (std::find(ids.begin(), ids.end(), id) == ids.end())
del.push_back(id);
}
for (StrList::const_iterator i = del.begin(); i != del.end(); ++i)
{
const std::string& id = *i;
event(id, model_[id].type, hbba_msgs::Event::DES_OFF);
if (model_[id].flags & FLAG_INT)
event(id, model_[id].type, hbba_msgs::Event::INT_OFF);
if (model_[id].flags & FLAG_EXP)
event(id, model_[id].type, hbba_msgs::Event::EXP_OFF);
model_.erase(id);
}
// Then, generate events for new desires.
for (StrVec::const_iterator i = ids.begin(); i != ids.end(); ++i)
{
const std::string& id = *i;
if (model_.find(id) == model_.end())
{
model_[id].flags = FLAG_NONE;
model_[id].type = typeMap[id]; //set type in the model
event(id, model_[id].type, hbba_msgs::Event::DES_ON);
}
}
}
示例3:
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;
}
示例4: 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]));
}
}
示例5: process
bool TestPathops::process ()
{
#ifdef _MSC_VER
const char* paths [] = {"\\kokos\\banan", "d:\\Encyclopedia\\Data\\Genomes\\E.coli.K12\\proteins\\fasta\\", "", "\\", "\\ananas\\", NULL};
#else
const char* paths [] = {"/kokos/banan", "~/Encyclopedia/Data/Genomes/E.coli.K12/proteins/fasta/", "", "/", "/ananas/", NULL};
#endif
const char** path = paths;
for (; *path != NULL; path ++)
{
o_ << "Path " << *path << std::endl;
StrVec comps = split_path (*path);
o_ << "path " << *path << ", " << comps.size () << " components" << std::endl;
StrVec::const_iterator i = comps.begin ();
for (;i < comps.end (); i ++)
o_ << " '" << (*i).c_str () << "'" << std::endl;
std::string rejoined = join_path (comps);
o_ << " Rejoined: " << rejoined.c_str () << std::endl;
}
std::string jp = join_path ("kokos", "banan", "ananas", "yabloko", NULL);
o_ << jp.c_str () << std::endl;
jp = join_path ("", "kokos", NULL);
o_ << jp.c_str () << std::endl;
jp = join_path ("", NULL);
o_ << jp.c_str () << std::endl;
jp = join_path ("kokos", NULL);
o_ << jp.c_str () << std::endl;
jp = join_path (NULL);
o_ << jp.c_str () << std::endl;
return true;
}
示例6:
StrVec::StrVec(const StrVec &s)
{
using namespace std;
auto newdata = alloc_n_copy(s.begin(), s.end());
elements = newdata.first;
first_free = cap = newdata.second;
}
示例7: main
int main()
{
StrVec v = {"Gone", "with", "the"};
v.push_back("winds");
for_each(v.begin(), v.end(), [](const string &s) {cout << s << " ";});
cout << endl;
return 0;
}
示例8:
StrVec::StrVec(const StrVec& orig)
{
// call alloc_n_copy to allocate space and copy data
auto newData = alloc_n_copy(orig.begin(), orig.end());
// update pointers
elements = newData.first;
first_free = cap = newData.second;
}
示例9: display
void display(const StrVec &s)
{
for (auto p = s.begin(); p != s.end(); ++p)
{
std::cout << *p << " ";
}
std::cout << std::endl;
}
示例10:
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();
}
示例11: main
int main()
{
StrVec vec;
vec.reserve(6);
std::cout << "capacity(reserve to 6): " << vec.capacity() << std::endl;
vec.reserve(4);
std::cout << "capacity(reserve to 4): " << vec.capacity() << std::endl;
vec.push_back("hello");
vec.push_back("world");
vec.resize(4);
for (auto i = vec.begin(); i != vec.end(); ++i)
std::cout << *i << std::endl;
std::cout << "-EOF-" << std::endl;
vec.resize(1);
for (auto i = vec.begin(); i != vec.end(); ++i)
std::cout << *i << std::endl;
std::cout << "-EOF-" << std::endl;
StrVec vec_list{ "hello", "world", "pezy" };
for (auto i = vec_list.begin(); i != vec_list.end(); ++i)
std::cout << *i << " ";
std::cout << std::endl;
// Test operator==
const StrVec const_vec_list{ "hello", "world", "pezy" };
if (vec_list == const_vec_list)
for (const auto &str : const_vec_list)
std::cout << str << " ";
std::cout << std::endl;
// Test operator<
const StrVec const_vec_list_small{ "hello", "pezy", "ok" };
std::cout << (const_vec_list_small < const_vec_list) << std::endl;
// Test []
std::cout << const_vec_list_small[1] << std::endl;
}
示例12:
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;
}
示例13: main
int main()
{
StrVec str;
str.push_back("adf");
str.push_back("sdfd");
for (auto i = str.begin(); i != str.end(); ++i)
cout << *i << ends;
cout << endl;
return 0;
}
示例14: make_temp_fname
std::string make_temp_fname (const char* tmpdir, const char* prefix)
{
// if directory not passed in, guess one
std::string tn = temp_dir (tmpdir);;
// if prefix not passed in, use default
if (!prefix) prefix = DEFAULT_TEMP_FILE_PREFIX;
// get temp directory listing
StrVec dircontent = listdir (tn);
// find all entries matching prefix and having numeric postfix, get list of numbers
UintSet postfixes;
unsigned prefix_len = prefix ? strlen (prefix) : 0;
for (StrVec::iterator ii = dircontent.begin (); ii != dircontent.end (); ii ++)
{
// check if prefix matches
if (prefix_len && (ii->substr (0, prefix_len) != prefix))
continue;
// check if postfix is numeric and get the number
unsigned number = 0;
std::string::iterator sitr;
for (sitr = ii->begin () + prefix_len; sitr != ii->end (); sitr ++)
{
number *= 10;
if (!isdigit (*sitr))
break;
else
number += *sitr - '0';
}
if (sitr != ii->end ())
continue;
// store number to postfixes set
postfixes.insert (number);
}
// now retrieve the numbers using first gap
// make a set for quick presence check
unsigned prev = 0;
for (UintSet::iterator nitr = postfixes.begin (); nitr != postfixes.end (); nitr ++)
if (prev + 1 < *nitr)
break; // found the gap in sequence
else
prev = *nitr;
if (prev == std::numeric_limits<unsigned>::max ()) // just for sanity :)
ers << "No more temp file names available for prefix " << (prefix ? prefix : "") << " in directory " << tn << Throw;
// prev + 1 is the right number
std::ostringstream name (tn, std::ios::out | std::ios::app);
name << PATH_SEPARATOR;
if (prefix) name << prefix;
name << prev + 1;
return name.str ();
}
示例15:
//! copy constructor
StrVec::StrVec(const StrVec &s)
{
/**
* @brief newData is a pair of pointers pointing to newly allocated and copied
* range : [b, e)
*/
std::pair<std::string*, std::string*>
newData = alloc_n_copy(s.begin(), s.end());
element = newData.first;
first_free = cap = newData.second;
}