目录遍历,递归和非递归算法

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);
}

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值