Debian Codegraph @

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

raw
1 // ==++==
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // ==--==
6 /*============================================================
7 **
8 ** Interface: IReadOnlyDictionary<TKey, TValue>
9 **
10 ** <OWNER>matell</OWNER>
11 **
12 ** Purpose: Base interface for read-only generic dictionaries.
13 **
14 ===========================================================*/
15 using System;
16 using System.Diagnostics.Contracts;
17
18 namespace System.Collections.Generic
19 {
20 // Provides a read-only view of a generic dictionary.
21 #if CONTRACTS_FULL
22 [ContractClass(typeof(IReadOnlyDictionaryContract<,>))]
23 #endif
24 public interface IReadOnlyDictionary<TKey, TValue> : IReadOnlyCollection<KeyValuePair<TKey, TValue>>
25 {
26 bool ContainsKey(TKey key);
27 bool TryGetValue(TKey key, out TValue value);
28
29 TValue this[TKey key] { get; }
30 IEnumerable<TKey> Keys { get; }
31 IEnumerable<TValue> Values { get; }
32 }
33
34 #if CONTRACTS_FULL
35 [ContractClassFor(typeof(IReadOnlyDictionary<,>))]
36 internal abstract class IReadOnlyDictionaryContract<TKey, TValue> : IReadOnlyDictionary<TKey, TValue>
37 {
38 bool IReadOnlyDictionary<TKey, TValue>.ContainsKey(TKey key)
39 {
40 return default(bool);
41 }
42
43 bool IReadOnlyDictionary<TKey, TValue>.TryGetValue(TKey key, out TValue value)
44 {
45 value = default(TValue);
46 return default(bool);
47 }
48
49 TValue IReadOnlyDictionary<TKey, TValue>.this[TKey key]
50 {
51 get { return default(TValue); }
52 }
53
54 IEnumerable<TKey> IReadOnlyDictionary<TKey, TValue>.Keys {
55 get {
56 Contract.Ensures(Contract.Result<IEnumerable<TKey>>() != null);
57 return default(IEnumerable<TKey>);
58 }
59 }
60
61 IEnumerable<TValue> IReadOnlyDictionary<TKey, TValue>.Values {
62 get {
63 Contract.Ensures(Contract.Result<IEnumerable<TValue>>() != null);
64 return default(IEnumerable<TValue>);
65 }
66 }
67
68 IEnumerator<KeyValuePair<TKey, TValue>> IEnumerable<KeyValuePair<TKey, TValue>>.GetEnumerator()
69 {
70 return default(IEnumerator<KeyValuePair<TKey, TValue>>);
71 }
72
73 int IReadOnlyCollection<KeyValuePair<TKey, TValue>>.Count {
74 get {
75 return default(int);
76 }
77 }
78
79 IEnumerator IEnumerable.GetEnumerator()
80 {
81 return default(IEnumerator);
82 }
83 }
84 #endif
85 }