本文整理汇总了C++中sequence::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ sequence::push_back方法的具体用法?C++ sequence::push_back怎么用?C++ sequence::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sequence
的用法示例。
在下文中一共展示了sequence::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy_list_to_sequence
static void copy_list_to_sequence(sequence &dst, const list &src) {
for(int i = 0; i < len(src); ++i) {
dst.push_back(extract<unsigned int>(src[i]));
}
}
示例2: main
int main(int argc, char **argv)
{
using namespace std;
unsigned j;
/*
cout << "Input number of tests (for each pattern size): " << flush;
cin >> Number_Of_Tests;
cout << "Input number of pattern sizes: " << flush;
cin >> Number_Of_Pattern_Sizes;
cout << "Input pattern sizes: " << flush;
*/
if (argc < 4)
return 1;
Number_Of_Tests = strtoul(argv[1], NULL, 10);
Number_Of_Pattern_Sizes = strtoul(argv[2], NULL, 10);
vector<unsigned> Pattern_Size(Number_Of_Pattern_Sizes);
for (j = 0; j < Number_Of_Pattern_Sizes; ++j)
Pattern_Size[j] = strtoul(argv[j + 3], NULL, 10);
cout << "\nNumber of tests: " << Number_Of_Tests << endl;
cout << "Pattern sizes: ";
for (j = 0; j < Number_Of_Pattern_Sizes; ++j)
cout << Pattern_Size[j] << " ";
cout << endl;
ifstream ifs(textFileName);
char C;
while (ifs.get(C))
S1.push_back(C);
cout << S1.size() << " characters read." << endl;
ifstream dictfile(wordFileName);
typedef istream_iterator<string> string_input;
typedef map<int, vector<sequence>, less<int> > map_type;
map_type dictionary;
sequence S;
string S0;
string_input si(dictfile);
while (si != string_input()) {
S0 = *si++;
S.erase(S.begin(), S.end());
copy(S0.begin(), S0.end() - 1, back_inserter(S));
dictionary[S.size()].push_back(S);
}
for (j = 0; j < Number_Of_Pattern_Sizes; ++j) {
vector<sequence>& diction = dictionary[Pattern_Size[j]];
if (diction.size() > Number_Of_Tests) {
vector<sequence> temp;
unsigned Skip_Amount = diction.size() / Number_Of_Tests;
for (unsigned T = 0; T < Number_Of_Tests; ++T) {
temp.push_back(diction[T * Skip_Amount]);
}
diction = temp;
}
Increment = (S1.size() - Pattern_Size[j]) / Number_Of_Tests;
cout << "\n\n-----------------------------------------------------------\n"
<< "Searching for patterns of size " << Pattern_Size[j]
<< "..." << endl;
cout << "(" << Number_Of_Tests << " patterns from the text, "
<< dictionary[Pattern_Size[j]].size() << " from the dictionary)" << endl;
cerr << Pattern_Size[j] << " " << flush;
Base_Time = 0.0;
for (int k = 0; k < number_of_algorithms; ++k) {
if (k != 0)
cout << "Timing " << algorithm_names[k] << ":" << endl;
Run(k, S1, dictionary[Pattern_Size[j]], Pattern_Size[j]);
}
cout << endl;
}
cerr << endl;
}