Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/rx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Rx/NET/Source/System.Reactive.Linq/Reactive/Internal/HashSet.cs')
-rw-r--r--Rx/NET/Source/System.Reactive.Linq/Reactive/Internal/HashSet.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/Rx/NET/Source/System.Reactive.Linq/Reactive/Internal/HashSet.cs b/Rx/NET/Source/System.Reactive.Linq/Reactive/Internal/HashSet.cs
new file mode 100644
index 0000000..f1fce24
--- /dev/null
+++ b/Rx/NET/Source/System.Reactive.Linq/Reactive/Internal/HashSet.cs
@@ -0,0 +1,45 @@
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
+
+#if NO_HASHSET
+using System;
+using System.Collections.Generic;
+
+namespace System.Reactive
+{
+ class HashSet<T>
+ {
+ private readonly Dictionary<T, object> _set;
+ private bool _hasNull;
+
+ public HashSet(IEqualityComparer<T> comparer)
+ {
+ _set = new Dictionary<T, object>(comparer);
+ _hasNull = false;
+ }
+
+ public bool Add(T value)
+ {
+ //
+ // Note: The box instruction in the IL will be erased by the JIT in case T is
+ // a value type. See GroupBy for more information.
+ //
+ if (value == null)
+ {
+ if (_hasNull)
+ return false;
+
+ _hasNull = true;
+ return true;
+ }
+ else
+ {
+ if (_set.ContainsKey(value))
+ return false;
+
+ _set[value] = null;
+ return true;
+ }
+ }
+ }
+}
+#endif \ No newline at end of file