Debian Codegraph @

mcs/class/referencesource/mscorlib/system/collections/generic/icollection.cs

raw
1 // ==++==
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // ==--==
6 /*============================================================
7 **
8 ** Interface: ICollection
9 **
10 ** <OWNER>kimhamil</OWNER>
11 **
12 **
13 ** Purpose: Base interface for all generic collections.
14 **
15 **
16 ===========================================================*/
17 namespace System.Collections.Generic {
18 using System;
19 using System.Runtime.CompilerServices;
20 using System.Diagnostics.Contracts;
21
22 // Base interface for all collections, defining enumerators, size, and
23 // synchronization methods.
24
25 // Note that T[] : IList<T>, and we want to ensure that if you use
26 // IList<YourValueType>, we ensure a YourValueType[] can be used
27 // without jitting. Hence the TypeDependencyAttribute on SZArrayHelper.
28 // This is a special hack internally though - see VM\compile.cpp.
29 // The same attribute is on IEnumerable<T> and ICollection<T>.
30 #if CONTRACTS_FULL
31 [ContractClass(typeof(ICollectionContract<>))]
32 #endif
33 [TypeDependencyAttribute("System.SZArrayHelper")]
34 public interface ICollection<T> : IEnumerable<T>
35 {
36 // Number of items in the collections.
37 int Count { get; }
38
39 bool IsReadOnly { get; }
40
41 void Add(T item);
42
43 void Clear();
44
45 bool Contains(T item);
46
47 // CopyTo copies a collection into an Array, starting at a particular
48 // index into the array.
49 //
50 void CopyTo(T[] array, int arrayIndex);
51
52 //void CopyTo(int sourceIndex, T[] destinationArray, int destinationIndex, int count);
53
54 bool Remove(T item);
55 }
56
57 #if CONTRACTS_FULL
58 [ContractClassFor(typeof(ICollection<>))]
59 internal abstract class ICollectionContract<T> : ICollection<T>
60 {
61 int ICollection<T>.Count {
62 get {
63 Contract.Ensures(Contract.Result<int>() >= 0);
64 return default(int);
65 }
66 }
67
68 bool ICollection<T>.IsReadOnly {
69 get { return default(bool); }
70 }
71
72 void ICollection<T>.Add(T item)
73 {
74 //Contract.Ensures(((ICollection<T>)this).Count == Contract.OldValue(((ICollection<T>)this).Count) + 1); // not threadsafe
75 }
76
77 void ICollection<T>.Clear()
78 {
79 }
80
81 bool ICollection<T>.Contains(T item)
82 {
83 return default(bool);
84 }
85
86 void ICollection<T>.CopyTo(T[] array, int arrayIndex)
87 {
88 }
89
90 bool ICollection<T>.Remove(T item)
91 {
92 return default(bool);
93 }
94
95 IEnumerator<T> IEnumerable<T>.GetEnumerator()
96 {
97 return default(IEnumerator<T>);
98 }
99
100 IEnumerator IEnumerable.GetEnumerator()
101 {
102 return default(IEnumerator);
103 }
104 }
105 #endif // CONTRACTS_FULL
106 }