diff options
author | Oren Novotny <oren@novotny.org> | 2014-02-26 10:08:50 -0500 |
---|---|---|
committer | Oren Novotny <oren@novotny.org> | 2014-02-26 10:08:50 -0500 |
commit | 4816fdea71230c76b1b5b43d61e5f29824851fdf (patch) | |
tree | f29c97c3341c7ac862ebd98452d1bad9e00738fb /crypto/src/util/collections/HashSet.cs | |
parent | Add git files (diff) | |
download | BouncyCastle.NET-ed25519-4816fdea71230c76b1b5b43d61e5f29824851fdf.tar.xz |
Add BouncyCastle PCL files
Diffstat (limited to 'crypto/src/util/collections/HashSet.cs')
-rw-r--r-- | crypto/src/util/collections/HashSet.cs | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/crypto/src/util/collections/HashSet.cs b/crypto/src/util/collections/HashSet.cs new file mode 100644 index 000000000..1facb58e3 --- /dev/null +++ b/crypto/src/util/collections/HashSet.cs @@ -0,0 +1,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; } + } + } +} |