本文整理汇总了C++中forward_list::push_front方法的典型用法代码示例。如果您正苦于以下问题:C++ forward_list::push_front方法的具体用法?C++ forward_list::push_front怎么用?C++ forward_list::push_front使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forward_list
的用法示例。
在下文中一共展示了forward_list::push_front方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: listCopy
void listCopy(forward_list<T> L, forward_list<T> &P) // reverse L and put it into P
{
for(typename forward_list<T>::iterator start = L.begin() ; start != L.end() ; ++start)
{
P.push_front(*start);
}
}
示例2: copieListe
void copieListe(forward_list<TypeInfo> maListeOriginale, forward_list<TypeInfo>& maListecopiee) {
// pour conserver l'ordre dans la copie il faut :
// 1 empiler les valeurs de la liste originale en faisant cun parcours complet gauche droite de la liste
// 2 dépiler les valeurs de la liste originale en les insérant en tête de la copie
// on peut au choix utiliser la ListeChaineePile déjà définie, une liste chainée en avant de la STL, ou une pile de la STL
// AVEC UNE LISTE de la STL
forward_list<TypeInfo> maCopieInversee;
// étape 1
for (TypeInfo& val : maListeOriginale) {
maCopieInversee.push_front(val);
} // end for
// étape 2
for (TypeInfo& val : maCopieInversee) {
maListecopiee.push_front(val);
} // end for
/*
// AVEC UNE PILE de la STL
stack<TypeInfo> maPile;
// étape 1
for (TypeInfo& val : maListeOriginale) {
maPile.push(val);
} // end for
// étape 2
while (!maPile.empty()) {
maListecopiee.push_front(maPile.top());
maPile.pop();
} // end while
*/
}
示例3: parseQuotes
static void parseQuotes(istringstream& result, forward_list<pair<string,quote_>>& quotes)
{
string row;
string date;
float price[4];
result.ignore(256, '\n');
while(result.peek() != EOF)
{
getline(result, date, ',');
result>> row;
result.ignore();
sscanf(row.c_str(), "%f,%f,%f,%f", &price[0], &price[1], &price[2], &price[3]);
quotes.push_front(pair<string,quote_>(date, {price[0], price[1], price[2], price[3]}));
}
}
示例4: parser2
// input: the reference to the hashing table, list1 and list2 from parser1, the reference to
// the resultpointer) table/vector/array, the second tree
// output: the updated resultpointer) repository
// what's that:
// local list3: in-order position (in list1) list, vector<int> data type
// local h2: the stack behavior temporary hashing table (we always need a stack for the traversal)
// local h21: the final resultpointer) hashing table; it seems that we don't need h21
void parser2(char * tree, unordered_map<long int, double> * resultpointer)
{
//unordered_map<double, forward_list<MRCA>> h2, h21;
// temporarily we dob't consider the h21
unordered_map<double, forward_list<MRCA *>> h2;
// the following stack is local; should be released after this function
forward_list<double> stack;
// to get the actual start of a tree; from the "(" to start
int i = 0;
while(tree[i] != '(')i++;
while(tree[i] != ';')
{
if(tree[i] == ',' || tree[i] == ' ' || tree[i] == ';')
{
i++;
continue;
}
if(tree[i] == '(')
{
i++;
stack.push_front(-1);
continue;
}
if(tree[i] >= 48 && tree[i] <= 57)
{
char node[5];
int j = 0;
while(tree[i] != '.')
{
node[j++] = tree[i++];
}
node[j] = '\0';
long int node_value = string_long(node);
while(tree[i++] != ':');
char tmrca[20]; // I give this double type number 20 effective digits; it is just kidding of course
j = 0;
while(tree[i] != ',' && tree[i] != ')' && tree[i] != '\0')
{
tmrca[j++] = tree[i];
i++;
}
tmrca[j] = '\0';
double tmrca_value = string_double(tmrca);
// for the list and the stack:
// the list is used to put all the leaves in-order, using their previous positions
// the stack is usual as the previous one, assisting in the stack operation
list3.push_back(list2[node_value-1]);
/*
// DEBUG: see the positions of specific nodes in list3
if(node_value == 64 || node_value == 170)
{
cout << node_value << " " << int(list3.size()-1) << endl;
}
*/
if(stack.front() == -1)
{
stack.front() = tmrca_value;
double tmrca_value1 = partial_tMRCA(tmrca_value, PRECISION);
std::unordered_map<double, forward_list<MRCA *>>::const_iterator got = h2.find(tmrca_value1);
if(got == h2.end())
{
forward_list<MRCA *> temp;
MRCA * mrcapointer = (MRCA *)malloc(sizeof(MRCA));
(*mrcapointer) = {tmrca_value, int(list3.size()-1), int(list3.size()-1), 0};
temp.push_front(mrcapointer);
h2[tmrca_value1] = temp;
//h2.emplace(partial_tMRCA(stack.front(), PRECISION), temp);
}
else
{
MRCA * mrcapointer = (MRCA *)malloc(sizeof(MRCA));
(*mrcapointer) = {tmrca_value, int(list3.size()-1), int(list3.size()-1), 0};
h2[tmrca_value1].push_front(mrcapointer);
//got->second.push_front(mrca);
//h2[tmrca_value1].push_front(mrca);
}
}
else
{
h2[partial_tMRCA(stack.front(), PRECISION)].front()->end = list3.size()-1;
}
continue;
}
//.........这里部分代码省略.........