本文整理汇总了C++中forward_list::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ forward_list::begin方法的具体用法?C++ forward_list::begin怎么用?C++ forward_list::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forward_list
的用法示例。
在下文中一共展示了forward_list::begin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: retirerPions
bool Case::retirerPions(forward_list<Pion*> fl, int nbPionsToDel) {
bool all_deleted = true;
if(nbPions - nbPionsToDel < 0) {
cout << "[Case.cpp/retirerPions] Erreur : Impossible de retirer les pions. Pas assez de pions." << endl;
return false;
}
else {
for(auto it=fl.begin() ; it!=fl.end(); ++it) {
//cout << "RETIRER PIONS ON PASSE : " << *it << endl;
if(!retirerPion(*it)) {
cout << "[Case.cpp/retirerPions] Erreur : Impossible de retirer le pion. Il n'est pas present." << endl;
all_deleted = false;
}
}
}
return all_deleted;
}
示例2: IBD_hash
// input: two trees waiting to be compared, the resultpointer) repository
// output: the updated resultpointer) repository (it's a hashing table with "long int: int" pair in)
void IBD_hash(char * tree1, char * tree2, unordered_map<long int, double> * resultpointer)
{
// NOTE:
// in practice, we can store the second hashing table, and when next time we enter, we can directly use it
// we can achieve this by storing the second hashing table as global in this scope
(*resultpointer).clear();
// clean the global variables
h11.clear();
list1.clear();
list3.clear();
rubbish.clear();
parser1(tree1);
// DEBUG
/*
for(auto itr = h11[124.8].begin(); itr != h11[124.8].end(); itr ++)
{
cout << (*itr)->tMRCA << ":" << (*itr)->start << " " << (*itr)->middle << " " << (*itr)->end << " " << endl;
}
*/
parser2(tree2, resultpointer);
// empty the temporary rubbish pool
for(auto itr = rubbish.begin(); itr != rubbish.end(); itr ++)
{
free(*itr);
}
// free the h11 memory for fear that there will be memory overflow
for(auto itr = h11.begin(); itr != h11.end(); itr ++)
{
// (*itr) is a forward_list<MRCA *>
for(auto itr1 = (*itr).second.begin(); itr1 != (*itr).second.end(); itr1 ++)
{
// (*itr1) is a (MRCA *)
free(*itr1);
}
}
return;
}
示例3: getInfoAtPosit
TypeInfo getInfoAtPosit(forward_list<TypeInfo> laListe, int laPosition) throw (PrecondVioleeExcep) {
// version itérative
// un itérateur sur la liste
auto it = laListe.begin();
int positionCourante = 1;
// tantque l'on a pas atteint laPosition et que l'on est pas à la fin de la liste
while ((positionCourante < laPosition) && (it != laListe.end())) {
positionCourante++;
// avancer dans la liste sur l'itérateur
++it;
}
if (it != laListe.end()) { // si on eu accès à laPosition
// rendre l'élément pointé par l'itérateur
return *it;
} else { // sinon on lève une exception
throw PrecondVioleeExcep("Accès imposible à l'indice " + to_string(laPosition));
}
}
示例4: merge
// Merge a connected compontent of lines to a new line with width.
void merge(const forward_list<LineSegW*>& component, LineSegW& out) {
// TODO: in principle no loop/collection is necessary
// Note: profiling indicates this is not even close to a bottleneck, so ok for now
float maxw = 0.0f;
forward_list<Point*> component2i;
for (auto vec = component.begin(); vec != component.end(); ++vec) {
component2i.push_front(&(*vec)->s);
component2i.push_front(&(*vec)->e);
if ((*vec)->width > maxw) {
maxw = (*vec)->width;
}
}
line_fit(component2i, out);
out.width = max(maxw, out.width);
}
示例5: replace
void replace(forward_list<string> &sflst, const string &str1, const string &str2)
{
int flag = 0;
auto prev = sflst.before_begin();
auto curr = sflst.begin();
auto end = sflst.end();
while (curr != end)
if (*curr == str1)
{
curr = sflst.emplace_after(curr, str2);
flag = 1;
}
else
{
prev = curr;
++curr;
}
if (!flag)
sflst.insert_after(prev, str2);
}
示例6: FindStringInsertString
void FindStringInsertString(forward_list<string>& strlist, string strtofind, string strtoinsert)
{
forward_list<string>::iterator current = strlist.begin();
forward_list<string>::iterator pre = strlist.before_begin();
bool findflag = false;
while (current != strlist.end())
{
if (*current == strtofind)
{
current = strlist.insert_after(current,strtoinsert);
findflag = true;
}
pre = current;
current++;
}
if (!findflag)
{
strlist.insert_after(pre, strtoinsert);
}
return;
}