예제 #1
0
        /// <summary>
        /// Split into Names and Addresses
        /// </summary>
        /// <param name="records"></param>
        static void SplitRecords(List <Record> records)
        {
            // Itterate only once over records O(n)
            foreach (var r in records)
            {
                // Names
                if (!_names.ContainsKey(r.FirstName))
                {
                    _names.Add(r.FirstName, 1);
                }
                else
                {
                    _names[r.FirstName]++;
                }

                if (!_names.ContainsKey(r.LastName))
                {
                    _names.Add(r.LastName, 1);
                }
                else
                {
                    _names[r.LastName]++;
                }

                // Address
                var streetOnly = _addressParser.GetStreetName(r.Address);
                if (!_addresses.ContainsKey(streetOnly))
                {
                    _addresses.Add(streetOnly, r.Address);
                }
            }
        }