//Trả về danh sách path thỏa mãn vào hàng đợi chứa 1 từ trong số các từ tìm kiếm public static void GetAll_BFS(Queue <string> queue_result, string root, string[] keyword, XFilter boloc)//tìm kiếm theo chiều rộng { Queue <string> pending = new Queue <string>(); pending.Enqueue(root); while (pending.Count != 0) { var path = pending.Dequeue(); string[] next = null; try { next = XFolder.GetDirectories(path).ToArray(); //lấy ra toàn bộ folder con foreach (var subdir in next) { pending.Enqueue(subdir); //cho vào trong stackif (next != null) all += next.Count(); } } catch { } if (next != null) { foreach (string item in next) //kiếm tra trong các folder tên có chứa chuối cần tìm { if (boloc.IsSatisfy(item) && XPath.IsEqualName(item, keyword)) { queue_result.Enqueue(item); } } } try { next = XFolder.GetFiles(path).ToArray(); //lấy ra toàn bộ file trong folder đấy } catch { } if (next != null) { foreach (string item in next) //kiếm tra trong các file tên có chứa chuối cần tìm { if (boloc.IsSatisfy(item) && XPath.IsEqualName(item, keyword)) { queue_result.Enqueue(item); } } } } }
//Trả về danh sách path thỏa mãn vào hàng đợi chứa 1 từ trong số các từ tìm kiếm public static void GetOne_BFS(Queue <string> queue_result, string root, string[] keyword, XFilter boloc)//tìm kiếm theo chiều rộng { var path = root; string[] next = null; try { next = XFolder.GetDirectories(path).ToArray(); //lấy ra toàn bộ folder con } catch { } if (next != null) { foreach (string item in next) //kiếm tra trong các folder tên có chứa chuối cần tìm { if (boloc.IsSatisfy(item) && XPath.IsEqualName(item, keyword)) { queue_result.Enqueue(item); } } } try { next = XFolder.GetFiles(path).ToArray(); //lấy ra toàn bộ file trong folder đấy } catch { } if (next != null) { foreach (string item in next) //kiếm tra trong các file tên có chứa chuối cần tìm { if (boloc.IsSatisfy(item) && XPath.IsEqualName(item, keyword)) { queue_result.Enqueue(item); } } } }