summary refs log tree commit diff
path: root/crypto/src/util/collections/EmptyEnumerable.cs
blob: a61a0789a32c7a0eadcdc4dec51bcb89e461bda7 (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
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"); }
		}
	}
}