Merge pull request #2964 from ludovic-henry/sgen-monocontext
[mono.git] / mcs / class / referencesource / System.Web / Util / EmptyCollection.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="EmptyCollection.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>                                                                
5 //------------------------------------------------------------------------------
6
7 /*
8  * EmptyCollection class
9  * 
10  * Copyright (c) 1999 Microsoft Corporation
11  */
12
13 namespace System.Web.Util {
14
15 using System.Collections;
16
17 /*
18  * Fast implementation of an empty collection
19  */
20 internal class EmptyCollection: ICollection, IEnumerator {
21
22     private static EmptyCollection s_theEmptyCollection = new EmptyCollection();
23
24     private EmptyCollection() { }
25
26     // Return the same instance all the time, since it's immutable
27     internal static EmptyCollection Instance { get { return s_theEmptyCollection; } }
28
29     // ICollection implementation
30     IEnumerator IEnumerable.GetEnumerator() { return this; }
31     public int Count { get { return 0; } }
32     bool ICollection.IsSynchronized { get { return true; } }
33     object ICollection.SyncRoot { get { return this; } }
34     public void CopyTo(Array array, int index) { }
35
36     // IEnumerator implementation
37     object IEnumerator.Current { get { return null; } }
38     bool IEnumerator.MoveNext() { return false; }
39     void IEnumerator.Reset() { }
40 }
41
42 }