@@ -25,9 +25,9 @@ public class UniqueIndex<TKey, T> : ICollectionIndex<T>, IDictionary<TKey, T>
25
25
public UniqueIndex (
26
26
string name ,
27
27
Func < T , GetKeyResponse < TKey > > getKey ,
28
- IDictionary < TKey , T > dictionary )
28
+ IDictionary < TKey , T > dictionary )
29
29
{
30
- this . Initialize ( name , getKey , dictionary ) ;
30
+ this . Initialize ( name , getKey , dictionary ) ;
31
31
}
32
32
33
33
/// <summary>
@@ -39,7 +39,7 @@ public UniqueIndex(
39
39
public UniqueIndex (
40
40
string name ,
41
41
Func < T , GetKeyResponse < TKey > > getKey ,
42
- SortOrder sortOrder )
42
+ SortOrder sortOrder )
43
43
{
44
44
IDictionary < TKey , T > dictionary ;
45
45
switch ( sortOrder )
@@ -50,7 +50,7 @@ public UniqueIndex(
50
50
51
51
case SortOrder . Descending :
52
52
var comparer = ReversedComparer < TKey > . Default ;
53
- dictionary = new SortedDictionary < TKey , T > ( comparer ) ;
53
+ dictionary = new SortedDictionary < TKey , T > ( comparer ) ;
54
54
break ;
55
55
56
56
case SortOrder . None :
@@ -61,7 +61,7 @@ public UniqueIndex(
61
61
throw new ArgumentException ( ) ;
62
62
}
63
63
64
- this . Initialize ( name , getKey , dictionary ) ;
64
+ this . Initialize ( name , getKey , dictionary ) ;
65
65
}
66
66
67
67
/// <summary>
@@ -80,11 +80,11 @@ public string Name
80
80
/// </summary>
81
81
/// <param name="key"></param>
82
82
/// <returns></returns>
83
- public T this [ TKey key ]
83
+ public T this [ TKey key ]
84
84
{
85
85
get
86
86
{
87
- return this . dictionary [ key ] ;
87
+ return this . dictionary [ key ] ;
88
88
}
89
89
90
90
set
@@ -99,9 +99,9 @@ public T this[ TKey key ]
99
99
/// <param name="key"></param>
100
100
/// <returns></returns>
101
101
[ Pure ]
102
- public bool ContainsKey ( TKey key )
102
+ public bool ContainsKey ( TKey key )
103
103
{
104
- return this . dictionary . ContainsKey ( key ) ;
104
+ return this . dictionary . ContainsKey ( key ) ;
105
105
}
106
106
107
107
#region ICollectionIndex<TKey,T> Members
@@ -133,9 +133,9 @@ public int Count
133
133
/// </summary>
134
134
/// <param name="array"></param>
135
135
/// <param name="arrayIndex"></param>
136
- public void CopyTo ( T [ ] array , int arrayIndex )
136
+ public void CopyTo ( T [ ] array , int arrayIndex )
137
137
{
138
- this . dictionary . Values . CopyTo ( array , arrayIndex ) ;
138
+ this . dictionary . Values . CopyTo ( array , arrayIndex ) ;
139
139
}
140
140
141
141
/// <summary>
@@ -144,9 +144,9 @@ public void CopyTo( T[] array, int arrayIndex )
144
144
/// <param name="key"></param>
145
145
/// <param name="item"></param>
146
146
/// <returns></returns>
147
- public bool TryGetValue ( TKey key , out T item )
147
+ public bool TryGetValue ( TKey key , out T item )
148
148
{
149
- return this . dictionary . TryGetValue ( key , out item ) ;
149
+ return this . dictionary . TryGetValue ( key , out item ) ;
150
150
}
151
151
152
152
/// <summary>
@@ -166,15 +166,15 @@ public IEnumerator<KeyValuePair<TKey, T>> GetEnumerator()
166
166
///
167
167
/// </summary>
168
168
/// <param name="item"></param>
169
- void ICollection < T > . Add ( T item )
169
+ void ICollection < T > . Add ( T item )
170
170
{
171
- var response = this . getKey ( item ) ;
171
+ var response = this . getKey ( item ) ;
172
172
173
173
if ( response . HasKey )
174
174
{
175
175
var key = response . Key ;
176
- Contract . Assert ( ! this . dictionary . ContainsKey ( key ) ) ;
177
- this . dictionary . Add ( key , item ) ;
176
+ Contract . Assert ( ! this . dictionary . ContainsKey ( key ) ) ;
177
+ this . dictionary . Add ( key , item ) ;
178
178
}
179
179
}
180
180
@@ -191,16 +191,16 @@ void ICollection<T>.Clear()
191
191
/// </summary>
192
192
/// <param name="item"></param>
193
193
/// <returns></returns>
194
- public bool Contains ( T item )
194
+ public bool Contains ( T item )
195
195
{
196
- Contract . Assert ( item != null ) ;
196
+ Contract . Assert ( item != null ) ;
197
197
198
- var response = this . getKey ( item ) ;
198
+ var response = this . getKey ( item ) ;
199
199
bool contains ;
200
200
201
201
if ( response . HasKey )
202
202
{
203
- contains = this . dictionary . ContainsKey ( response . Key ) ;
203
+ contains = this . dictionary . ContainsKey ( response . Key ) ;
204
204
}
205
205
else
206
206
{
@@ -215,16 +215,16 @@ public bool Contains( T item )
215
215
/// </summary>
216
216
/// <param name="item"></param>
217
217
/// <returns></returns>
218
- bool ICollection < T > . Remove ( T item )
218
+ bool ICollection < T > . Remove ( T item )
219
219
{
220
- Contract . Assert ( item != null ) ;
220
+ Contract . Assert ( item != null ) ;
221
221
222
- var response = this . getKey ( item ) ;
222
+ var response = this . getKey ( item ) ;
223
223
bool succeeded ;
224
224
225
225
if ( response . HasKey )
226
226
{
227
- succeeded = this . dictionary . Remove ( response . Key ) ;
227
+ succeeded = this . dictionary . Remove ( response . Key ) ;
228
228
}
229
229
else
230
230
{
@@ -269,7 +269,7 @@ IEnumerator IEnumerable.GetEnumerator()
269
269
/// </summary>
270
270
/// <param name="key"></param>
271
271
/// <param name="value"></param>
272
- void IDictionary < TKey , T > . Add ( TKey key , T value )
272
+ void IDictionary < TKey , T > . Add ( TKey key , T value )
273
273
{
274
274
throw new NotSupportedException ( ) ;
275
275
}
@@ -290,7 +290,7 @@ public ICollection<TKey> Keys
290
290
/// </summary>
291
291
/// <param name="key"></param>
292
292
/// <returns></returns>
293
- bool IDictionary < TKey , T > . Remove ( TKey key )
293
+ bool IDictionary < TKey , T > . Remove ( TKey key )
294
294
{
295
295
throw new NotSupportedException ( ) ;
296
296
}
@@ -314,7 +314,7 @@ public ICollection<T> Values
314
314
///
315
315
/// </summary>
316
316
/// <param name="item"></param>
317
- void ICollection < KeyValuePair < TKey , T > > . Add ( KeyValuePair < TKey , T > item )
317
+ void ICollection < KeyValuePair < TKey , T > > . Add ( KeyValuePair < TKey , T > item )
318
318
{
319
319
throw new NotSupportedException ( ) ;
320
320
}
@@ -324,7 +324,7 @@ void ICollection<KeyValuePair<TKey, T>>.Add( KeyValuePair<TKey, T> item )
324
324
/// </summary>
325
325
/// <param name="item"></param>
326
326
/// <returns></returns>
327
- bool ICollection < KeyValuePair < TKey , T > > . Contains ( KeyValuePair < TKey , T > item )
327
+ bool ICollection < KeyValuePair < TKey , T > > . Contains ( KeyValuePair < TKey , T > item )
328
328
{
329
329
throw new NotSupportedException ( ) ;
330
330
}
@@ -339,7 +339,7 @@ void ICollection<KeyValuePair<TKey, T>>.Clear()
339
339
/// </summary>
340
340
/// <param name="array"></param>
341
341
/// <param name="arrayIndex"></param>
342
- void ICollection < KeyValuePair < TKey , T > > . CopyTo ( KeyValuePair < TKey , T > [ ] array , int arrayIndex )
342
+ void ICollection < KeyValuePair < TKey , T > > . CopyTo ( KeyValuePair < TKey , T > [ ] array , int arrayIndex )
343
343
{
344
344
throw new NotSupportedException ( ) ;
345
345
}
@@ -349,18 +349,18 @@ void ICollection<KeyValuePair<TKey, T>>.CopyTo( KeyValuePair<TKey, T>[] array, i
349
349
/// </summary>
350
350
/// <param name="item"></param>
351
351
/// <returns></returns>
352
- public bool Remove ( KeyValuePair < TKey , T > item )
352
+ public bool Remove ( KeyValuePair < TKey , T > item )
353
353
{
354
354
throw new NotSupportedException ( ) ;
355
355
}
356
356
357
357
#endregion
358
358
359
- private void Initialize ( string name , Func < T , GetKeyResponse < TKey > > getKey , IDictionary < TKey , T > dictionary )
359
+ private void Initialize ( string name , Func < T , GetKeyResponse < TKey > > getKey , IDictionary < TKey , T > dictionary )
360
360
{
361
- Contract . Requires ( name != null ) ;
362
- Contract . Requires ( getKey != null ) ;
363
- Contract . Requires ( dictionary != null ) ;
361
+ Contract . Requires < ArgumentNullException > ( name != null ) ;
362
+ Contract . Requires < ArgumentNullException > ( getKey != null ) ;
363
+ Contract . Requires < ArgumentNullException > ( dictionary != null ) ;
364
364
365
365
this . name = name ;
366
366
this . getKey = getKey ;
0 commit comments