本文整理汇总了C++中FileIO::read_file_to_station_list方法的典型用法代码示例。如果您正苦于以下问题:C++ FileIO::read_file_to_station_list方法的具体用法?C++ FileIO::read_file_to_station_list怎么用?C++ FileIO::read_file_to_station_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileIO
的用法示例。
在下文中一共展示了FileIO::read_file_to_station_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
FileIO * file = new FileIO("tube.txt");
vector<Station *> station_list = file->read_file_to_station_list();
vector<Station *> sorted_list = file->read_file_to_station_list();
std::sort(sorted_list.begin(), sorted_list.end(), sort_by_name);
// print_all(sorted_list, station_list);
// search_by_keyword(sorted_list, station_list);
// mode_selection(sorted_list, station_list);
//test section
node<int> *_node = new node<int>();
// cout<<sorted_list[0]->get_station_index()<<endl;
_node->data = sorted_list[0]->get_station_index();
AVL<int> *tree = new AVL<int>(_node); //new binary_tree<int>(_node);
for(vector<Station *>::iterator it = sorted_list.begin() + 1;it != sorted_list.end();++it){
bool b_return = tree->insert((*it)->get_station_index());
// cout<<(*it)->get_station_index()<<" "<<b_return<<endl;
}
cout<<"done!"<<endl;
// tree->traverse_inorder(tree->root);
cout<<"Tree height is "<<tree->tree_height<<endl;
node<int> *returned_node = tree->search(0);
cout<<returned_node->data<<" "<<returned_node->height<<endl;
node<int> *rhs = tree->root;
// cout<<rhs->data<<" "<<rhs->height<<endl;
rhs = rhs->rhs;
node<int> min, max;
// cout<<"d 1"<<endl;
tree->find_min_from(rhs, min);
// cout<<"d 2"<<endl;
tree->find_max_from((tree->root)->lhs, max);
cout<<"min in right branch is "<<min.data<<" "<<min.height<<endl;
cout<<"max in left branch is "<<max.data<<" "<<max.height<<endl;
cout<<"depth is "<<tree->find_depth(tree->root)<<endl;
cout<<"left branch depth is "<<tree->find_depth((tree->root)->lhs)<<endl;
cout<<"right branch depth is "<<tree->find_depth((tree->root)->rhs)<<endl;
cout<<"balance factor is "<<tree->balance_factor(tree->root)<<endl;
cout<<"tree is balanced? "<<tree->is_balanced(tree->root)<<endl;
cout<<"tree root "<<(tree->root)->data<<endl;
// delete[] tree->root;
delete tree;
return 0;
}
示例2: main
int main(){
FileIO * file = new FileIO("tube.txt");
vector<Station *> station_list = file->read_file_to_station_list();
vector<Station *> sorted_list = file->read_file_to_station_list();
std::sort(sorted_list.begin(), sorted_list.end(), sort_by_name);
// print_all(sorted_list, station_list);
// search_by_keyword(sorted_list, station_list);
mode_selection(sorted_list, station_list);
//test section
/*
int start, end;
Station * result_station, *start_p, *end_p;
cout<<"Start: ";
cin>>start;
cout<<"End: ";
cin>>end;
if(station_validation(station_list, start) && station_validation(station_list, end)){
cout<<endl;
find_index(station_list, start_p, start);
find_index(station_list, end_p, end);
cout<<"Start from "<<start_p->get_station_name()<<" to "<<end_p->get_station_name()<<endl;
vector<int> result_path = A_star_start(station_list, start, end);
for(vector<int>::iterator it = result_path.begin();it != result_path.end() - 1;++it){
find_index(station_list, result_station, *it);
cout<<result_station->get_station_name()<<"->";
}
cout<<end_p->get_station_name()<<endl;
cout<<result_path.size()<<" stations in total."<<endl;
}
*/
return 0;
}