HashSet.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using System.Collections;
  4. namespace Org.BouncyCastle.Utilities.Collections
  5. {
  6. public class HashSet
  7. : ISet
  8. {
  9. private readonly IDictionary impl = Org.BouncyCastle.Utilities.Platform.CreateHashtable();
  10. public HashSet()
  11. {
  12. }
  13. public HashSet(IEnumerable s)
  14. {
  15. foreach (object o in s)
  16. {
  17. Add(o);
  18. }
  19. }
  20. public virtual void Add(object o)
  21. {
  22. impl[o] = null;
  23. }
  24. public virtual void AddAll(IEnumerable e)
  25. {
  26. foreach (object o in e)
  27. {
  28. Add(o);
  29. }
  30. }
  31. public virtual void Clear()
  32. {
  33. impl.Clear();
  34. }
  35. public virtual bool Contains(object o)
  36. {
  37. return impl.Contains(o);
  38. }
  39. public virtual void CopyTo(Array array, int index)
  40. {
  41. impl.Keys.CopyTo(array, index);
  42. }
  43. public virtual int Count
  44. {
  45. get { return impl.Count; }
  46. }
  47. public virtual IEnumerator GetEnumerator()
  48. {
  49. return impl.Keys.GetEnumerator();
  50. }
  51. public virtual bool IsEmpty
  52. {
  53. get { return impl.Count == 0; }
  54. }
  55. public virtual bool IsFixedSize
  56. {
  57. get { return impl.IsFixedSize; }
  58. }
  59. public virtual bool IsReadOnly
  60. {
  61. get { return impl.IsReadOnly; }
  62. }
  63. public virtual bool IsSynchronized
  64. {
  65. get { return impl.IsSynchronized; }
  66. }
  67. public virtual void Remove(object o)
  68. {
  69. impl.Remove(o);
  70. }
  71. public virtual void RemoveAll(IEnumerable e)
  72. {
  73. foreach (object o in e)
  74. {
  75. Remove(o);
  76. }
  77. }
  78. public virtual object SyncRoot
  79. {
  80. get { return impl.SyncRoot; }
  81. }
  82. }
  83. }
  84. #endif