/// <summary> /// Indexer /// </summary> /// <param name="key"></param> /// <returns></returns> public ICollection <TValue> this[TKey key] { get { return(InnerMap.GetOrAdd(key, k => new List <TValue>())); } set { if (value != null) { Add(key, value.ToArray <TValue>()); } else { this[key].Clear(); } } }
/// <summary> /// 해당 키에 값이 없다면 값을 넣고, 반환합니다. /// </summary> /// <param name="key"></param> /// <param name="valueFactory"></param> /// <returns></returns> public ICollection <TValue> GetOrAdd(TKey key, Func <TKey, ICollection <TValue> > valueFactory) { valueFactory.ShouldNotBeNull("valueFactory"); if (ContainsKey(key)) { var values = this[key]; foreach (var value in valueFactory(key)) { values.Add(value); } return(values); } return(InnerMap.GetOrAdd(key, valueFactory)); }
public ISet <TValue> GetOrAdd(TKey key, ISet <TValue> values) { return(InnerMap.GetOrAdd(key, k => values)); }
public ISet <TValue> GetOrAdd(TKey key, Func <TKey, ISet <TValue> > valuesFactory) { return(InnerMap.GetOrAdd(key, valuesFactory)); }