-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIDictionary.cs
More file actions
218 lines (206 loc) · 8.01 KB
/
IDictionary.cs
File metadata and controls
218 lines (206 loc) · 8.01 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
//
// Copyright © 2005 - 2007 Maksim Goleta. All rights reserved.
// GOLETAS PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
//
namespace Goletas.Collections
{
using System;
/// <summary>
/// Represents a collection of key/value pairs.
/// </summary>
/// <remarks>
/// <para>
/// Each element in the <see cref="IDictionary<K,V>"/> interface is a
/// key/value pair stored in the <see cref="KeyValuePair<K,V>"/> structure.
/// </para>
/// <para>
/// Each pair must have a unique <see cref="KeyValuePair<K,V>.Key"/>.
/// Implementations can vary in whether they allow the key to be a <c>null</c>
/// reference. The <see cref="KeyValuePair<K,V>.Value"/> can be a <c>null</c>
/// reference and does not have to be unique. The <see cref="IDictionary<K,V>"/>
/// interface allows the contained keys and values to be enumerated, but it does not
/// imply any particular sort order.
/// </para>
/// </remarks>
/// <typeparam name="K">
/// The type of keys in the <see cref="IDictionary<K,V>"/>.
/// </typeparam>
/// <typeparam name="V">
/// The type of values in the <see cref="IDictionary<K,V>"/>.
/// </typeparam>
public interface IDictionary<K, V> : System.Collections.Generic.IEnumerable<KeyValuePair<K, V>>
{
/// <summary>
/// Gets a value indicating whether the <see cref="IDictionary<K,V>"/>
/// is read-only.
/// </summary>
/// <value>
/// <c>true</c> if the <see cref="IDictionary<K,V>"/> is read-only;
/// otherwise, <c>false</c>.
/// </value>
/// <remarks>
/// A dictionary that is read-only does not allow the addition, removal or
/// modification of elements after the dictionary is created.
/// </remarks>
bool IsReadOnly
{
get;
}
/// <summary>
/// Adds an element with the provided <paramref name="key"/> and
/// <paramref name="value"/> to the <see cref="IDictionary<K,V>"/>.
/// </summary>
/// <param name="key">
/// The object to use as the key of the element to add.
/// </param>
/// <param name="value">
/// The object to use as the value of the element to add.
/// </param>
/// <returns>
/// <c>true</c> if the element was successfully added to the
/// <see cref="IDictionary<K,V>"/>; otherwise, <c>false</c>.
/// This method also returns <c>false</c> if a particular
/// <see cref="IDictionary<K,V>"/> implementation supports only unique
/// keys and the dictionary already contains the specified <paramref name="key"/>.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="key"/> is a <c>null</c> reference.
/// </exception>
/// <exception cref="NotSupportedException">
/// The <see cref="IDictionary<K,V>"/> is read-only.
/// </exception>
bool Add(K key, V value);
/// <summary>
/// Gets the number of key/value pairs contained in the <see cref="IDictionary<K,V>"/>.
/// </summary>
/// <value>
/// The number of key/value pairs contained in the <see cref="IDictionary<K,V>"/>.
/// </value>
int Count
{
get;
}
/// <summary>
/// Gets or sets the element with the specified <paramref name="key"/>.
/// </summary>
/// <value>
/// The element with the specified <paramref name="key"/>.
/// </value>
/// <param name="key">
/// The key of the element to get or set.
/// </param>
/// <returns>
/// The value of the element with the specified <paramref name="key"/>.
/// </returns>
/// <remarks>
/// You can use the <see cref="this"/> property to add new elements by setting
/// the value of a key that does not exist in the <see cref="IDictionary<K,V>"/>.
/// If the specified <paramref name="key"/> already exists in the dictionary,
/// setting the <see cref="this"/> property overwrites the old value.
/// </remarks>
/// <exception cref="ArgumentNullException">
/// <paramref name="key"/> is a <c>null</c> reference.
/// </exception>
/// <exception cref="System.Collections.Generic.KeyNotFoundException">
/// The property is retrieved and the <paramref name="key"/> is not found.
/// </exception>
/// <exception cref="NotSupportedException">
/// The property is set and the <see cref="IDictionary<K,V>"/> is read-only.
/// </exception>
V this[K key]
{
get;
set;
}
/// <summary>
/// Copies the <see cref="IDictionary<K,V>"/> key/value pairs to an existing
/// one-dimensional <see cref="Array"/>, starting at the specified array index.
/// </summary>
/// <param name="array">
/// The one-dimensional <see cref="Array"/> that is the destination of the
/// key/value pairs copied from this <see cref="IDictionary<K,V>"/>.
/// The <paramref name="array"/> must have zero-based indexing.
/// </param>
/// <param name="index">
/// The zero-based index in the <paramref name="array"/> at which copying begins.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="array"/> is a <c>null</c> reference.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="index"/> is outside of <paramref name="array"/> bounds.
/// </exception>
/// <exception cref="ArgumentException">
/// The number of key/value pairs in the source <see cref="IDictionary<K,V>"/>
/// is greater than the available space from the <paramref name="index"/> to the end
/// of the destination <paramref name="array"/>.
/// </exception>
void CopyTo(KeyValuePair<K, V>[] array, int index);
/// <summary>
/// Retrieves the value associated with the specified <paramref name="key"/>.
/// </summary>
/// <param name="key">
/// The key whose value to retrieve.
/// </param>
/// <param name="value">
/// If the key is found, the value associated with the specified <paramref name="key"/>;
/// otherwise, the default value for the type of the <paramref name="value"/> parameter.
/// </param>
/// <returns>
/// <c>true</c> if <see cref="IDictionary<K,V>"/> contains an element with the
/// specified <paramref name="key"/>; otherwise, <c>false</c>.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="key"/> is a <c>null</c> reference.
/// </exception>
bool Retrieve(K key, out V value);
/// <summary>
/// Gets an <see cref="ICollection<T>"/> containing the keys of the
/// <see cref="IDictionary<K,V>"/>.
/// </summary>
/// <value>
/// An <see cref="ICollection<T>"/> containing the keys of the
/// object that implements <see cref="IDictionary<K,V>"/>.
/// </value>
ICollection<K> Keys { get; }
/// <summary>
/// Gets an <see cref="ICollection<T>"/> containing the values of the
/// <see cref="IDictionary<K,V>"/>.
/// </summary>
/// <value>
/// An <see cref="ICollection<T>"/> containing the values of the
/// object that implements <see cref="IDictionary<K,V>"/>.
/// </value>
ICollection<V> Values { get; }
/// <summary>
/// Removes the element with the specified <paramref name="key"/>
/// from the <see cref="IDictionary<K,V>"/>.
/// </summary>
/// <param name="key">
/// The key of the element to remove.
/// </param>
/// <returns>
/// <c>true</c> if the element is successfully removed; otherwise, <c>false</c>.
/// This method also returns false if the <paramref name="key"/> was not found in
/// the original <see cref="IDictionary<K,V>"/>.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="key"/> is a <c>null</c> reference.
/// </exception>
/// <exception cref="NotSupportedException">
/// The <see cref="IDictionary<K,V>"/> is read-only.
/// </exception>
bool Remove(K key);
/// <summary>
/// Removes all key/value pairs from the <see cref="IDictionary<K,V>"/>.
/// </summary>
/// <remarks>
/// <see cref="Count"/> must be set to zero, and references to other objects
/// from key/value pairs of the dictionary must be released.
/// </remarks>
/// <exception cref="NotSupportedException">
/// The <see cref="IDictionary<K,V>"/> is read-only.
/// </exception>
void Clear();
}
}