本文整理汇总了C++中Dlist::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Dlist::clear方法的具体用法?C++ Dlist::clear怎么用?C++ Dlist::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dlist
的用法示例。
在下文中一共展示了Dlist::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Dlist<int> dlist;
int i=dlist.size();
std::cout<<i<<std::endl;
dlist.push_back(2);
for (int j1=0; j1<dlist.size(); ++j1)
std::cout<<dlist.value(j1+1)<<'-';
std::cout<<std::endl;
dlist.push_front(4);
for (int j2=0; j2<dlist.size(); ++j2)
std::cout<<dlist.value(j2+1)<<'-';
std::cout<<std::endl;
dlist.insert_after(7,1);
i=dlist.size();
std::cout<<i<<std::endl;
for (int j3=0; j3<dlist.size(); ++j3)
std::cout<<dlist.value(j3+1)<<'-';
std::cout<<std::endl;
dlist.reverse();
std::cout<<dlist.size()<<std::endl;
for (int j4=0; j4<dlist.size(); ++j4)
std::cout<<dlist.value(j4+1)<<'-';
std::cout<<std::endl;
dlist.clear();
std::cout<<dlist.size()<<std::endl;
return 0;
}
示例2: El_max_reduce_cpr_blocks
void El_max_reduce_cpr_blocks(Hyperblock *hb, Cont_cpr_match_result &match_result)
{
Dlist<Dlist< Pair<Op*, Op*> > > hb_cprblocks;
Dlist< Pair<Op*, Op*> > cur_cprblock;
Pair<Op*, Op*> cur_tuple;
Op *first_branch, *cur_branch, *cur_cmpp;
hb_cprblocks = match_result.cpr_blk_list;
if (hb_cprblocks.size() == 0) {
if (dbg(cpr, 2))
cdbg << "HB " << hb->id() << " has no cpr blocks" << endl;
return;
}
hb_br_preds.clear();
hb_ft_preds.clear();
for (Dlist_iterator<Dlist< Pair<Op*, Op*> > > d_iter(hb_cprblocks);
d_iter!=0; d_iter++) {
cur_cprblock = *d_iter;
El_normalize_cprblock(cur_cprblock);
first_branch = NULL;
for (Dlist_iterator<Pair<Op*, Op*> > d2_iter(cur_cprblock);
d2_iter!=0; d2_iter++) {
cur_tuple = *d2_iter;
cur_branch = cur_tuple.first;
cur_cmpp = cur_tuple.second;
if (first_branch == NULL) {
first_branch = cur_branch;
hb_br_preds.push_tail(cur_cmpp->dest(DEST1));
hb_ft_preds.push_tail(cur_cmpp->dest(DEST2));
continue;
}
El_collapse_compare_chain(hb, cur_cprblock, cur_branch, first_branch);
}
}
El_record_maxreduce_info_in_attr(hb);
}
示例3: main
int main(int argc,char* argv[]) {
Command cmd(argc,argv);
try {
string dic, board;
int cols, min, mode;
try {
board = cmd.index().get("board");
} catch(...) {
cout<<"No board given."<<endl;
throw;
}
try {
min = atoi(cmd.index().get("min").c_str());
} catch(...) {
cout<<"Setting minimum word length to 4"<<endl;
min=4;
}
try {
dic = cmd.index().get("dic");
for (int i = 0; i < (int)dic.size(); i++) {
if (!isalpha(dic[i])) {
dic[i]='_';
}
}
} catch(...) {
cout<<"Using default dictionary."<<endl;
dic = "words";
}
try {
mode = atoi(cmd.index().get("mode").c_str());
if(mode) mode=1;
}
catch(...) {cout<<"Using default mode 0"<<endl; mode=0;}
try {
cols = atoi(cmd.index().get("cols").c_str());
if(cols<2 || cols > 100) cols = 10;
}
catch(...) {cout<<"Using default output column count."<<endl; cols=10;}
Untangle s(board.c_str(), dic+".trie", min, mode);
cout<<"<p>Board size: "<<s.size()<<"<br>\n";
cout<<"Minimum word length: "<<min<<"<br>\n";
cout<<"Solve mode: "<<mode<<"</p>\n";
cout<<"<p>Board:\n";
print_html(s.get_letters(),min,s.size());
cout<<"</p>\n"<<endl;
cout<<"<p>Solving...<br>\n"<<endl;
s.untangle();
cout<<"<p>All done, sorting and displaying the result...</p>"<<endl;
Dlist<string> words;
cout<<"<h2>Alphabetically</h2>\n";
s.result().words_alpha(words);
tabular_result_output(words,cols);
words.clear();
cout<<"<h2>Longest-first</h2>\n";
s.result().words_length(words);
tabular_result_output(words,cols);
ofstream log("solve_log.txt");
if(log.fail()) throw "Could not open logfile for writing.";
log<<s.min()<<'\n'<<dic<<'\n'<<s.get_letters()<<'\n';
log.close();
cout<<"<p>"<</*s.num_words()<<" words found. */"Solution complete.</p>\n";
}
catch(string e) {
cout<<e<<endl;
cout<<"Error in getting program parameters."<<endl;
}
catch(char* e) {
cout<<e<<endl;
}
catch(...) {
cout<<"Unspecified error occurred. Please e-mail the author with the parameters that caused this condition."<<endl;
}
cout<<"<p>Boggle/Tangleword solver by Michael Hecht (c) 1999-2004</p>\n";
return 0;
}