public PhoneEntry[] ListEntries(int startPositon, int count) { if (startPositon < 0 || startPositon + count > this.caseInsensitiveKeyName.Count) { return(null); } PhoneEntry[] list = new PhoneEntry[count]; for (int i = startPositon; i <= startPositon + count - 1; i++) { PhoneEntry entry = this.phoneEntrySorted[i]; list[i - startPositon] = entry; } return(list); }
public bool AddPhone(string name, IEnumerable <string> phoneNumbers) { string caseInsensitiveName = name.ToLowerInvariant(); PhoneEntry entry; bool isNotExistingNumber = !this.caseInsensitiveKeyName.TryGetValue(caseInsensitiveName, out entry); if (isNotExistingNumber) { entry = new PhoneEntry(); entry.Name = name; entry.numbers = new HashSet <string>(); this.caseInsensitiveKeyName.Add(caseInsensitiveName, entry); this.phoneEntrySorted.Add(entry); } foreach (var number in phoneNumbers) { this.keyNumberValueEntry.Add(number, entry); } entry.numbers.UnionWith(phoneNumbers); return(isNotExistingNumber); }