Advertisement
Guest User

Untitled

a guest
May 18th, 2017
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. using System.Collections.Generic;
  2.  
  3. public class MPDictionary<TKey, TValue> : Dictionary<TKey, TValue>
  4. {
  5. /*
  6. * Properties
  7. */
  8.  
  9. public new TValue this[TKey key]
  10. {
  11. get
  12. {
  13. TValue result;
  14.  
  15. TryGetValue(key, out result);
  16.  
  17. return result;
  18. }
  19. set
  20. {
  21. base[key] = value;
  22. }
  23. }
  24.  
  25.  
  26. /*
  27. * Methods
  28. */
  29.  
  30. public MPDictionary() : base()
  31. {
  32.  
  33. }
  34.  
  35. public MPDictionary(int capacity, System.Collections.Generic.IEqualityComparer<TKey> comparer) : base(capacity, comparer)
  36. {
  37.  
  38. }
  39.  
  40.  
  41. public MPDictionary<TKey, TValue> Clone()
  42. {
  43. MPDictionary<TKey, TValue> result = new MPDictionary<TKey, TValue>(this.Count, this.Comparer);
  44.  
  45. foreach (KeyValuePair<TKey, TValue> entry in this)
  46. {
  47. result.Add(entry.Key, entry.Value);
  48. }
  49.  
  50. return result;
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement