, , . ( ), , , URL-, - , , Dictionary<string, int>, , :
var source = Enumerable.Range(0, 300000).Select(x => Guid.NewGuid().ToString()).Select(x => x.Substring(0, 4) + ".com/" + x.Substring(4, 10));
var targets = Enumerable.Range(0, 900).Select(x => Guid.NewGuid().ToString().Substring(0, 4) + ".com").Distinct();
var tally = targets.ToDictionary(x => x, x => 0);
Func<string, string> naiveDomainExtractor = x=> x.Split('/')[0];
foreach(var line in source)
{
var domain = naiveDomainExtractor(line);
if(tally.ContainsKey(domain)) tally[domain]++;
}
... , .
In truth, your domain extractor may be a little more complicated, but it probably won't be very intense, and if you have multiple cores, you can speed things up with ConcurrentDictionary<string, int>and Parallel.ForEach.
source
share