QueueDictionary.cs 635 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections.Generic;
  2. namespace Base
  3. {
  4. public class QueueDictionary<T, K>
  5. {
  6. private readonly List<T> list = new List<T>();
  7. private readonly Dictionary<T, K> dictionary = new Dictionary<T, K>();
  8. public void Add(T t, K k)
  9. {
  10. this.list.Add(t);
  11. this.dictionary.Add(t, k);
  12. }
  13. public bool Remove(T t)
  14. {
  15. this.list.Remove(t);
  16. this.dictionary.Remove(t);
  17. return true;
  18. }
  19. public int Count
  20. {
  21. get
  22. {
  23. return this.list.Count;
  24. }
  25. }
  26. public T FirstKey
  27. {
  28. get
  29. {
  30. return this.list[0];
  31. }
  32. }
  33. public K this[T t]
  34. {
  35. get
  36. {
  37. return this.dictionary[t];
  38. }
  39. }
  40. }
  41. }