/// <summary> /// Selects items keys by the specified index key. /// </summary> public IEnumerable <int> SelectItemKeys(object indexKey) { if (ItemGroups.TryGetValue(CastIndexKey(indexKey), out IndexGroup group)) { foreach (int key in group.Keys) { yield return(key); } } }
/// <summary> /// Selects items by the specified index key. /// </summary> public IEnumerable SelectItems(object indexKey) { if (ItemGroups.TryGetValue(CastIndexKey(indexKey), out IndexGroup group)) { foreach (object item in group.Values) { yield return(item); } } }
/// <summary> /// Selects items by the specified index key. /// </summary> public IEnumerable SelectItems(int indexKey) { if (ItemGroups.TryGetValue(indexKey, out SortedDictionary <int, object> group)) { foreach (object item in group.Values) { yield return(item); } } }
/// <summary> /// Adds the item to the index. /// </summary> public void AddToIndex(object item, int itemKey) { if (item == null) { throw new ArgumentNullException(nameof(item)); } TKey indexKey = GetIndexKey(item); if (!ItemGroups.TryGetValue(indexKey, out IndexGroup group)) { group = new IndexGroup(); ItemGroups.Add(indexKey, group); } group[itemKey] = (TItem)item; }
/// <summary> /// Adds the item to the index. /// </summary> public void AddToIndex(object item, int itemKey) { if (item == null) { throw new ArgumentNullException(nameof(item)); } int indexKey = GetIndexKey(item); if (!ItemGroups.TryGetValue(indexKey, out SortedDictionary <int, object> group)) { group = new SortedDictionary <int, object>(); ItemGroups.Add(indexKey, group); } group[itemKey] = item; }
/// <summary> /// Removes the item from the index. /// </summary> public void RemoveFromIndex(object item, int itemKey) { if (item == null) { throw new ArgumentNullException(nameof(item)); } int indexKey = GetIndexKey(item); if (ItemGroups.TryGetValue(indexKey, out SortedDictionary <int, object> group)) { group.Remove(itemKey); if (group.Count == 0) { ItemGroups.Remove(indexKey); } } }
private void ParseItemGroup(string line) { if (IsStartOfState(line) || line.TrimStart().StartsWith(LineMarkers.ItemGroupEnd)) { return; } var itemGroupType = GetCurrentOrNewItemGroup(line); if (!ItemGroups.TryGetValue(itemGroupType, out var lines)) { lines = new List <string>(); ItemGroups[itemGroupType] = lines; } lines.Add(line); }