HashSet.cs 628 B

12345678910111213141516171819202122232425262728
  1. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
  2. #if NO_HASHSET
  3. using System;
  4. using System.Collections.Generic;
  5. namespace System.Reactive
  6. {
  7. class HashSet<T>
  8. {
  9. private Dictionary<T, object> _set;
  10. public HashSet(IEqualityComparer<T> comparer)
  11. {
  12. _set = new Dictionary<T, object>(comparer);
  13. }
  14. public bool Add(T value)
  15. {
  16. if (_set.ContainsKey(value))
  17. return false;
  18. _set[value] = null;
  19. return true;
  20. }
  21. }
  22. }
  23. #endif