summary refs log tree commit diff
path: root/Crypto/src/util/collections/EmptyEnumerable.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Crypto/src/util/collections/EmptyEnumerable.cs')
-rw-r--r--Crypto/src/util/collections/EmptyEnumerable.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/Crypto/src/util/collections/EmptyEnumerable.cs b/Crypto/src/util/collections/EmptyEnumerable.cs
new file mode 100644

index 000000000..a61a0789a --- /dev/null +++ b/Crypto/src/util/collections/EmptyEnumerable.cs
@@ -0,0 +1,44 @@ +using System; +using System.Collections; + +namespace Org.BouncyCastle.Utilities.Collections +{ + public sealed class EmptyEnumerable + : IEnumerable + { + public static readonly IEnumerable Instance = new EmptyEnumerable(); + + private EmptyEnumerable() + { + } + + public IEnumerator GetEnumerator() + { + return EmptyEnumerator.Instance; + } + } + + public sealed class EmptyEnumerator + : IEnumerator + { + public static readonly IEnumerator Instance = new EmptyEnumerator(); + + private EmptyEnumerator() + { + } + + public bool MoveNext() + { + return false; + } + + public void Reset() + { + } + + public object Current + { + get { throw new InvalidOperationException("No elements"); } + } + } +}