Free cookie consent management tool by TermsFeed Policy Generator

source: branches/CodeEditor/HeuristicLab.ExtLibs/HeuristicLab.NRefactory/5.5.0/NRefactory-5.5.0/Utils/EmptyList.cs @ 11700

Last change on this file since 11700 was 11700, checked in by jkarder, 9 years ago

#2077: created branch and added first version

File size: 2.7 KB
Line 
1// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4// software and associated documentation files (the "Software"), to deal in the Software
5// without restriction, including without limitation the rights to use, copy, modify, merge,
6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7// to whom the Software is furnished to do so, subject to the following conditions:
8//
9// The above copyright notice and this permission notice shall be included in all copies or
10// substantial portions of the Software.
11//
12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17// DEALINGS IN THE SOFTWARE.
18
19using System;
20using System.Collections;
21using System.Collections.Generic;
22using System.Collections.ObjectModel;
23
24namespace ICSharpCode.NRefactory
25{
26  [Serializable]
27  public sealed class EmptyList<T> : IList<T>, IEnumerator<T>
28    #if NET_4_5
29    , IReadOnlyList<T>
30    #endif
31  {
32    public static readonly EmptyList<T> Instance = new EmptyList<T>();
33   
34    private EmptyList() {}
35   
36    public T this[int index] {
37      get { throw new ArgumentOutOfRangeException("index"); }
38      set { throw new ArgumentOutOfRangeException("index"); }
39    }
40   
41    public int Count {
42      get { return 0; }
43    }
44   
45    bool ICollection<T>.IsReadOnly {
46      get { return true; }
47    }
48   
49    int IList<T>.IndexOf(T item)
50    {
51      return -1;
52    }
53   
54    void IList<T>.Insert(int index, T item)
55    {
56      throw new NotSupportedException();
57    }
58   
59    void IList<T>.RemoveAt(int index)
60    {
61      throw new NotSupportedException();
62    }
63   
64    void ICollection<T>.Add(T item)
65    {
66      throw new NotSupportedException();
67    }
68   
69    void ICollection<T>.Clear()
70    {
71    }
72   
73    bool ICollection<T>.Contains(T item)
74    {
75      return false;
76    }
77   
78    void ICollection<T>.CopyTo(T[] array, int arrayIndex)
79    {
80    }
81   
82    bool ICollection<T>.Remove(T item)
83    {
84      return false;
85    }
86   
87    IEnumerator<T> IEnumerable<T>.GetEnumerator()
88    {
89      return this;
90    }
91   
92    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
93    {
94      return this;
95    }
96   
97    T IEnumerator<T>.Current {
98      get { return default(T); }
99    }
100   
101    object IEnumerator.Current {
102      get { return default(T); }
103    }
104   
105    void IDisposable.Dispose()
106    {
107    }
108   
109    bool IEnumerator.MoveNext()
110    {
111      return false;
112    }
113   
114    void IEnumerator.Reset()
115    {
116    }
117  }
118}
Note: See TracBrowser for help on using the repository browser.