SiroKuro #4428(2007/11/27 08:47 GMT) [ C# ] Rating0/0=0.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
using System; using System.Collections.Generic; static class Program { static void Main() { string[] pathList = {"aaa/bbb", "aaa/ccc", "aaa/ddd/eee", "bbb/ddd/eee", "bbb/ddd/fff"}; Console.WriteLine("[{0}]", string.Join(", ", Ls(pathList, "aaa/"))); Console.WriteLine("[{0}]", string.Join(", ", Ls(pathList, "aaa/ddd/"))); Console.WriteLine("[{0}]", string.Join(", ", Ls(pathList, "bbb/"))); Console.WriteLine("[{0}]", string.Join(", ", Ls(pathList, "bbb/ddd/"))); } static string[] Ls(string[] paths, string pattern) { SortedList<string, string> list = new SortedList<string, string>(); Array.ForEach(paths, delegate(string x) { if (x.StartsWith(pattern)) { x = x.Substring(pattern.Length); int i = x.IndexOf('/'); list[i < 0 ? x : x.Substring(0, i + 1)] = null; } }); return new List<string>(list.Keys).ToArray(); } }
Rating0/0=0.00-0+
[ reply ]
SiroKuro
#4428()
[
C#
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]