索引遍历,递归和非递归算法
目录遍历,递归和非递归算法
vckbase上那个搜索顺序和递归算法的搜索顺序不同,哥这个就是递归的顺序
vckbase上那个搜索顺序和递归算法的搜索顺序不同,哥这个就是递归的顺序
void search(string file_exp, string folder, reg_exp* rexp==NULL) { if ( !rexp ) { file1? ==> file[a-zA-Z0-9]{1,1} file* ==> file[a-zA-Z0-9]{0,} rexp = new reg_exp("..."); } foreach(ifile in folder) { if ifile is file { if rexp.test( ifile ) ret.puch_bach(ifile); } else { search(file_exp, ifle, rexp) } } } // 非递归算法 /// 队列加强 class queue { void push_at_end() // 在队列尾部插入 void pop_at_front() // 出队列 void push_at_front(vector)// 在队列插入 } // 搜索目录path中文件名符合regexp的文件 search_files_at_path(regexp, path) { } // 获取path中所有子目录 get_child_paths_at_path(path) { } void search_no_recur(v_path, regexp) { queue.push_at_end(v_path) while( !queue.empty() ) { curr_path = queue.pop_at_front(); search_files_at_path(regexp, curr_path); path_vector = get_child_paths_at_path(curr_path); queue.push_at_front(path_vector); } }