summary refs log tree commit diff
path: root/crypto/src/util/collections/HashSet.cs
blob: 1facb58e3a551be182951d0411274297fa098805 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using System.Collections;

namespace Org.BouncyCastle.Utilities.Collections
{
	public class HashSet
		: ISet
	{
		private readonly IDictionary impl = Platform.CreateHashtable();

		public HashSet()
		{
		}

		public HashSet(IEnumerable s)
		{
			foreach (object o in s)
			{
				Add(o);
			}
		}

		public virtual void Add(object o)
		{
			impl[o] = null;
		}

		public virtual void AddAll(IEnumerable e)
		{
			foreach (object o in e)
			{
				Add(o);
			}
		}

		public virtual void Clear()
		{
			impl.Clear();
		}

		public virtual bool Contains(object o)
		{
			return impl.Contains(o);
		}

		public virtual void CopyTo(Array array, int index)
		{
			impl.Keys.CopyTo(array, index);
		}

		public virtual int Count
		{
			get { return impl.Count; }
		}

		public virtual IEnumerator GetEnumerator()
		{
			return impl.Keys.GetEnumerator();
		}

		public virtual bool IsEmpty
		{
			get { return impl.Count == 0; }
		}

		public virtual bool IsFixedSize
		{
			get { return impl.IsFixedSize; }
		}

		public virtual bool IsReadOnly
		{
			get { return impl.IsReadOnly; }
		}

		public virtual bool IsSynchronized
		{
			get { return impl.IsSynchronized; }
		}

		public virtual void Remove(object o)
		{
			impl.Remove(o);
		}

		public virtual void RemoveAll(IEnumerable e)
		{
			foreach (object o in e)
			{
				Remove(o);
			}
		}

		public virtual object SyncRoot
		{
			get { return impl.SyncRoot; }
		}
	}
}