2 using System
.Collections
.Generic
;
7 public class Multidict
<KeyType
, ValueType
> : System
.Collections
.IEnumerable
9 protected Dictionary
<KeyType
, List
<ValueType
>> m_dict
= new Dictionary
<KeyType
, List
<ValueType
>>();
15 public List
<ValueType
> Get(KeyType key
)
17 List
<ValueType
> items
;
18 if (m_dict
.TryGetValue(key
, out items
))
25 public bool Add(KeyType key
, ValueType
value)
27 return Add(key
, value, false);
30 public bool Add(KeyType key
, ValueType
value, bool bAllowDups
)
32 List
<ValueType
> items
;
33 if (!m_dict
.TryGetValue(key
, out items
))
35 items
= new List
<ValueType
>();
38 if (!items
.Contains(value) || bAllowDups
)
46 public System
.Collections
.IEnumerator
GetEnumerator()
48 return m_dict
.GetEnumerator();