1
|
/*
|
2
|
Copyright (c) 2003-2006 Niels Kokholm and Peter Sestoft
|
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
of this software and associated documentation files (the "Software"), to deal
|
5
|
in the Software without restriction, including without limitation the rights
|
6
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
copies of the Software, and to permit persons to whom the Software is
|
8
|
furnished to do so, subject to the following conditions:
|
9
|
|
10
|
The above copyright notice and this permission notice shall be included in
|
11
|
all copies or substantial portions of the Software.
|
12
|
|
13
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
SOFTWARE.
|
20
|
*/
|
21
|
|
22
|
using System;
|
23
|
using System.Text;
|
24
|
using System.Diagnostics;
|
25
|
using SCG = System.Collections.Generic;
|
26
|
namespace C5
|
27
|
{
|
28
|
/// <summary>
|
29
|
/// An advanced interface to operations on an array. The array is viewed as an
|
30
|
/// <see cref="T:C5.IList`1"/> of fixed size, and so all operations that would change the
|
31
|
/// size of the array will be invalid (and throw <see cref="T:C5.FixedSizeCollectionException"/>
|
32
|
/// </summary>
|
33
|
/// <typeparam name="T"></typeparam>
|
34
|
public class WrappedArray<T> : IList<T>, SCG.IList<T>
|
35
|
{
|
36
|
class InnerList : ArrayList<T>
|
37
|
{
|
38
|
internal InnerList(T[] array) { this.array = array; size = array.Length; }
|
39
|
}
|
40
|
ArrayList<T> innerlist;
|
41
|
//TODO: remember a ref to the wrapped array in WrappedArray to save a little on indexing?
|
42
|
WrappedArray<T> underlying;
|
43
|
|
44
|
/// <summary>
|
45
|
///
|
46
|
/// </summary>
|
47
|
/// <param name="wrappedarray"></param>
|
48
|
public WrappedArray(T[] wrappedarray) { innerlist = new InnerList(wrappedarray); }
|
49
|
|
50
|
//for views
|
51
|
WrappedArray(ArrayList<T> arraylist, WrappedArray<T> underlying) { innerlist = arraylist; this.underlying = underlying; }
|
52
|
|
53
|
#region IList<T> Members
|
54
|
|
55
|
/// <summary>
|
56
|
///
|
57
|
/// </summary>
|
58
|
/// <value></value>
|
59
|
public T First { get { return innerlist.First; } }
|
60
|
|
61
|
/// <summary>
|
62
|
///
|
63
|
/// </summary>
|
64
|
/// <value></value>
|
65
|
public T Last { get { return innerlist.Last; } }
|
66
|
|
67
|
/// <summary>
|
68
|
///
|
69
|
/// </summary>
|
70
|
/// <param name="index"></param>
|
71
|
/// <returns></returns>
|
72
|
public T this[int index]
|
73
|
{
|
74
|
get { return innerlist[index]; }
|
75
|
set { innerlist[index] = value; }
|
76
|
}
|
77
|
|
78
|
/// <summary>
|
79
|
///
|
80
|
/// </summary>
|
81
|
/// <param name="filter"></param>
|
82
|
/// <returns></returns>
|
83
|
public IList<T> FindAll(Fun<T, bool> filter) { return innerlist.FindAll(filter); }
|
84
|
|
85
|
/// <summary>
|
86
|
///
|
87
|
/// </summary>
|
88
|
/// <typeparam name="V"></typeparam>
|
89
|
/// <param name="mapper"></param>
|
90
|
/// <returns></returns>
|
91
|
public IList<V> Map<V>(Fun<T, V> mapper) { return innerlist.Map<V>(mapper); }
|
92
|
|
93
|
/// <summary>
|
94
|
///
|
95
|
/// </summary>
|
96
|
/// <typeparam name="V"></typeparam>
|
97
|
/// <param name="mapper"></param>
|
98
|
/// <param name="equalityComparer"></param>
|
99
|
/// <returns></returns>
|
100
|
public IList<V> Map<V>(Fun<T, V> mapper, SCG.IEqualityComparer<V> equalityComparer) { return innerlist.Map<V>(mapper, equalityComparer); }
|
101
|
|
102
|
/// <summary>
|
103
|
/// ???? should we throw NotRelevantException
|
104
|
/// </summary>
|
105
|
/// <value></value>
|
106
|
public bool FIFO
|
107
|
{
|
108
|
get { throw new FixedSizeCollectionException(); }
|
109
|
set { throw new FixedSizeCollectionException(); }
|
110
|
}
|
111
|
|
112
|
/// <summary>
|
113
|
///
|
114
|
/// </summary>
|
115
|
public virtual bool IsFixedSize
|
116
|
{
|
117
|
get { return true; }
|
118
|
}
|
119
|
|
120
|
/// <summary>
|
121
|
///
|
122
|
/// </summary>
|
123
|
/// <param name="index"></param>
|
124
|
/// <param name="item"></param>
|
125
|
public void Insert(int index, T item)
|
126
|
{
|
127
|
throw new FixedSizeCollectionException();
|
128
|
}
|
129
|
|
130
|
/// <summary>
|
131
|
///
|
132
|
/// </summary>
|
133
|
/// <param name="pointer"></param>
|
134
|
/// <param name="item"></param>
|
135
|
public void Insert(IList<T> pointer, T item)
|
136
|
{
|
137
|
throw new FixedSizeCollectionException();
|
138
|
}
|
139
|
|
140
|
/// <summary>
|
141
|
///
|
142
|
/// </summary>
|
143
|
/// <param name="item"></param>
|
144
|
public void InsertFirst(T item)
|
145
|
{
|
146
|
throw new FixedSizeCollectionException();
|
147
|
}
|
148
|
|
149
|
/// <summary>
|
150
|
///
|
151
|
/// </summary>
|
152
|
/// <param name="item"></param>
|
153
|
public void InsertLast(T item)
|
154
|
{
|
155
|
throw new FixedSizeCollectionException();
|
156
|
}
|
157
|
|
158
|
/// <summary>
|
159
|
///
|
160
|
/// </summary>
|
161
|
/// <typeparam name="U"></typeparam>
|
162
|
/// <param name="i"></param>
|
163
|
/// <param name="items"></param>
|
164
|
public void InsertAll<U>(int i, System.Collections.Generic.IEnumerable<U> items) where U : T
|
165
|
{
|
166
|
throw new FixedSizeCollectionException();
|
167
|
}
|
168
|
|
169
|
/// <summary>
|
170
|
///
|
171
|
/// </summary>
|
172
|
/// <returns></returns>
|
173
|
public T Remove()
|
174
|
{
|
175
|
throw new FixedSizeCollectionException();
|
176
|
}
|
177
|
|
178
|
/// <summary>
|
179
|
///
|
180
|
/// </summary>
|
181
|
/// <returns></returns>
|
182
|
public T RemoveFirst()
|
183
|
{
|
184
|
throw new FixedSizeCollectionException();
|
185
|
}
|
186
|
|
187
|
/// <summary>
|
188
|
///
|
189
|
/// </summary>
|
190
|
/// <returns></returns>
|
191
|
public T RemoveLast()
|
192
|
{
|
193
|
throw new FixedSizeCollectionException();
|
194
|
}
|
195
|
|
196
|
/// <summary>
|
197
|
///
|
198
|
/// </summary>
|
199
|
/// <param name="start"></param>
|
200
|
/// <param name="count"></param>
|
201
|
/// <returns></returns>
|
202
|
public IList<T> View(int start, int count)
|
203
|
{
|
204
|
return new WrappedArray<T>((ArrayList<T>)innerlist.View(start, count), underlying ?? this);
|
205
|
}
|
206
|
|
207
|
/// <summary>
|
208
|
///
|
209
|
/// </summary>
|
210
|
/// <param name="item"></param>
|
211
|
/// <returns></returns>
|
212
|
public IList<T> ViewOf(T item)
|
213
|
{
|
214
|
return new WrappedArray<T>((ArrayList<T>)innerlist.ViewOf(item), underlying ?? this);
|
215
|
}
|
216
|
|
217
|
/// <summary>
|
218
|
///
|
219
|
/// </summary>
|
220
|
/// <param name="item"></param>
|
221
|
/// <returns></returns>
|
222
|
public IList<T> LastViewOf(T item)
|
223
|
{
|
224
|
return new WrappedArray<T>((ArrayList<T>)innerlist.LastViewOf(item), underlying ?? this);
|
225
|
}
|
226
|
|
227
|
/// <summary>
|
228
|
///
|
229
|
/// </summary>
|
230
|
/// <value></value>
|
231
|
public IList<T> Underlying { get { return underlying; } }
|
232
|
|
233
|
/// <summary>
|
234
|
///
|
235
|
/// </summary>
|
236
|
/// <value></value>
|
237
|
public int Offset { get { return innerlist.Offset; } }
|
238
|
|
239
|
/// <summary>
|
240
|
///
|
241
|
/// </summary>
|
242
|
/// <value></value>
|
243
|
public bool IsValid { get { return innerlist.IsValid; } }
|
244
|
|
245
|
/// <summary>
|
246
|
///
|
247
|
/// </summary>
|
248
|
/// <param name="offset"></param>
|
249
|
/// <returns></returns>
|
250
|
public IList<T> Slide(int offset) { return innerlist.Slide(offset); }
|
251
|
|
252
|
/// <summary>
|
253
|
///
|
254
|
/// </summary>
|
255
|
/// <param name="offset"></param>
|
256
|
/// <param name="size"></param>
|
257
|
/// <returns></returns>
|
258
|
public IList<T> Slide(int offset, int size) { return innerlist.Slide(offset, size); }
|
259
|
|
260
|
/// <summary>
|
261
|
///
|
262
|
/// </summary>
|
263
|
/// <param name="offset"></param>
|
264
|
/// <returns></returns>
|
265
|
public bool TrySlide(int offset) { return innerlist.TrySlide(offset); }
|
266
|
|
267
|
/// <summary>
|
268
|
///
|
269
|
/// </summary>
|
270
|
/// <param name="offset"></param>
|
271
|
/// <param name="size"></param>
|
272
|
/// <returns></returns>
|
273
|
public bool TrySlide(int offset, int size) { return innerlist.TrySlide(offset, size); }
|
274
|
|
275
|
/// <summary>
|
276
|
///
|
277
|
/// </summary>
|
278
|
/// <param name="otherView"></param>
|
279
|
/// <returns></returns>
|
280
|
public IList<T> Span(IList<T> otherView) { return innerlist.Span(((WrappedArray<T>)otherView).innerlist); }
|
281
|
|
282
|
/// <summary>
|
283
|
///
|
284
|
/// </summary>
|
285
|
public void Reverse() { innerlist.Reverse(); }
|
286
|
|
287
|
/// <summary>
|
288
|
///
|
289
|
/// </summary>
|
290
|
/// <returns></returns>
|
291
|
public bool IsSorted() { return innerlist.IsSorted(); }
|
292
|
|
293
|
/// <summary>
|
294
|
///
|
295
|
/// </summary>
|
296
|
/// <param name="comparer"></param>
|
297
|
/// <returns></returns>
|
298
|
public bool IsSorted(SCG.IComparer<T> comparer) { return innerlist.IsSorted(comparer); }
|
299
|
|
300
|
/// <summary>
|
301
|
///
|
302
|
/// </summary>
|
303
|
public void Sort() { innerlist.Sort(); }
|
304
|
|
305
|
/// <summary>
|
306
|
///
|
307
|
/// </summary>
|
308
|
/// <param name="comparer"></param>
|
309
|
public void Sort(SCG.IComparer<T> comparer) { innerlist.Sort(comparer); }
|
310
|
|
311
|
/// <summary>
|
312
|
///
|
313
|
/// </summary>
|
314
|
public void Shuffle() { innerlist.Shuffle(); }
|
315
|
|
316
|
/// <summary>
|
317
|
///
|
318
|
/// </summary>
|
319
|
/// <param name="rnd"></param>
|
320
|
public void Shuffle(Random rnd) { innerlist.Shuffle(rnd); }
|
321
|
|
322
|
#endregion
|
323
|
|
324
|
#region IIndexed<T> Members
|
325
|
|
326
|
/// <summary>
|
327
|
///
|
328
|
/// </summary>
|
329
|
/// <value></value>
|
330
|
public Speed IndexingSpeed { get { return Speed.Constant; } }
|
331
|
|
332
|
/// <summary>
|
333
|
///
|
334
|
/// </summary>
|
335
|
/// <param name="start"></param>
|
336
|
/// <param name="count"></param>
|
337
|
/// <returns></returns>
|
338
|
public IDirectedCollectionValue<T> this[int start, int count] { get { return innerlist[start, count]; } }
|
339
|
|
340
|
/// <summary>
|
341
|
///
|
342
|
/// </summary>
|
343
|
/// <param name="item"></param>
|
344
|
/// <returns></returns>
|
345
|
public int IndexOf(T item) { return innerlist.IndexOf(item); }
|
346
|
|
347
|
/// <summary>
|
348
|
///
|
349
|
/// </summary>
|
350
|
/// <param name="item"></param>
|
351
|
/// <returns></returns>
|
352
|
public int LastIndexOf(T item) { return innerlist.LastIndexOf(item); }
|
353
|
|
354
|
/// <summary>
|
355
|
///
|
356
|
/// </summary>
|
357
|
/// <param name="predicate"></param>
|
358
|
/// <returns></returns>
|
359
|
public int FindIndex(Fun<T, bool> predicate) { return innerlist.FindIndex(predicate); }
|
360
|
|
361
|
/// <summary>
|
362
|
///
|
363
|
/// </summary>
|
364
|
/// <param name="predicate"></param>
|
365
|
/// <returns></returns>
|
366
|
public int FindLastIndex(Fun<T, bool> predicate) { return innerlist.FindLastIndex(predicate); }
|
367
|
|
368
|
/// <summary>
|
369
|
///
|
370
|
/// </summary>
|
371
|
/// <param name="i"></param>
|
372
|
/// <returns></returns>
|
373
|
public T RemoveAt(int i) { throw new FixedSizeCollectionException(); }
|
374
|
|
375
|
/// <summary>
|
376
|
///
|
377
|
/// </summary>
|
378
|
/// <param name="start"></param>
|
379
|
/// <param name="count"></param>
|
380
|
public void RemoveInterval(int start, int count) { throw new FixedSizeCollectionException(); }
|
381
|
|
382
|
#endregion
|
383
|
|
384
|
#region ISequenced<T> Members
|
385
|
|
386
|
/// <summary>
|
387
|
///
|
388
|
/// </summary>
|
389
|
/// <returns></returns>
|
390
|
public int GetSequencedHashCode() { return innerlist.GetSequencedHashCode(); }
|
391
|
|
392
|
/// <summary>
|
393
|
///
|
394
|
/// </summary>
|
395
|
/// <param name="that"></param>
|
396
|
/// <returns></returns>
|
397
|
public bool SequencedEquals(ISequenced<T> that) { return innerlist.SequencedEquals(that); }
|
398
|
|
399
|
#endregion
|
400
|
|
401
|
#region ICollection<T> Members
|
402
|
/// <summary>
|
403
|
///
|
404
|
/// </summary>
|
405
|
/// <value></value>
|
406
|
public Speed ContainsSpeed { get { return Speed.Linear; } }
|
407
|
|
408
|
/// <summary>
|
409
|
///
|
410
|
/// </summary>
|
411
|
/// <returns></returns>
|
412
|
public int GetUnsequencedHashCode() { return innerlist.GetUnsequencedHashCode(); }
|
413
|
|
414
|
/// <summary>
|
415
|
///
|
416
|
/// </summary>
|
417
|
/// <param name="that"></param>
|
418
|
/// <returns></returns>
|
419
|
public bool UnsequencedEquals(ICollection<T> that) { return innerlist.UnsequencedEquals(that); }
|
420
|
|
421
|
/// <summary>
|
422
|
///
|
423
|
/// </summary>
|
424
|
/// <param name="item"></param>
|
425
|
/// <returns></returns>
|
426
|
public bool Contains(T item) { return innerlist.Contains(item); }
|
427
|
|
428
|
/// <summary>
|
429
|
///
|
430
|
/// </summary>
|
431
|
/// <param name="item"></param>
|
432
|
/// <returns></returns>
|
433
|
public int ContainsCount(T item) { return innerlist.ContainsCount(item); }
|
434
|
|
435
|
/// <summary>
|
436
|
///
|
437
|
/// </summary>
|
438
|
/// <returns></returns>
|
439
|
public ICollectionValue<T> UniqueItems() { return innerlist.UniqueItems(); }
|
440
|
|
441
|
/// <summary>
|
442
|
///
|
443
|
/// </summary>
|
444
|
/// <returns></returns>
|
445
|
public ICollectionValue<KeyValuePair<T, int>> ItemMultiplicities() { return innerlist.ItemMultiplicities(); }
|
446
|
|
447
|
/// <summary>
|
448
|
///
|
449
|
/// </summary>
|
450
|
/// <typeparam name="U"></typeparam>
|
451
|
/// <param name="items"></param>
|
452
|
/// <returns></returns>
|
453
|
public bool ContainsAll<U>(System.Collections.Generic.IEnumerable<U> items) where U : T
|
454
|
{ return innerlist.ContainsAll(items); }
|
455
|
|
456
|
/// <summary>
|
457
|
///
|
458
|
/// </summary>
|
459
|
/// <param name="item"></param>
|
460
|
/// <returns></returns>
|
461
|
public bool Find(ref T item) { return innerlist.Find(ref item); }
|
462
|
|
463
|
/// <summary>
|
464
|
///
|
465
|
/// </summary>
|
466
|
/// <param name="item"></param>
|
467
|
/// <returns></returns>
|
468
|
public bool FindOrAdd(ref T item) { throw new FixedSizeCollectionException(); }
|
469
|
|
470
|
/// <summary>
|
471
|
///
|
472
|
/// </summary>
|
473
|
/// <param name="item"></param>
|
474
|
/// <returns></returns>
|
475
|
public bool Update(T item) { throw new FixedSizeCollectionException(); }
|
476
|
|
477
|
/// <summary>
|
478
|
///
|
479
|
/// </summary>
|
480
|
/// <param name="item"></param>
|
481
|
/// <param name="olditem"></param>
|
482
|
/// <returns></returns>
|
483
|
public bool Update(T item, out T olditem) { throw new FixedSizeCollectionException(); }
|
484
|
|
485
|
/// <summary>
|
486
|
///
|
487
|
/// </summary>
|
488
|
/// <param name="item"></param>
|
489
|
/// <returns></returns>
|
490
|
public bool UpdateOrAdd(T item) { throw new FixedSizeCollectionException(); }
|
491
|
|
492
|
/// <summary>
|
493
|
///
|
494
|
/// </summary>
|
495
|
/// <param name="item"></param>
|
496
|
/// <param name="olditem"></param>
|
497
|
/// <returns></returns>
|
498
|
public bool UpdateOrAdd(T item, out T olditem) { throw new FixedSizeCollectionException(); }
|
499
|
|
500
|
/// <summary>
|
501
|
///
|
502
|
/// </summary>
|
503
|
/// <param name="item"></param>
|
504
|
/// <returns></returns>
|
505
|
public bool Remove(T item) { throw new FixedSizeCollectionException(); }
|
506
|
|
507
|
/// <summary>
|
508
|
///
|
509
|
/// </summary>
|
510
|
/// <param name="item"></param>
|
511
|
/// <param name="removeditem"></param>
|
512
|
/// <returns></returns>
|
513
|
public bool Remove(T item, out T removeditem) { throw new FixedSizeCollectionException(); }
|
514
|
|
515
|
/// <summary>
|
516
|
///
|
517
|
/// </summary>
|
518
|
/// <param name="item"></param>
|
519
|
public void RemoveAllCopies(T item) { throw new FixedSizeCollectionException(); }
|
520
|
|
521
|
/// <summary>
|
522
|
///
|
523
|
/// </summary>
|
524
|
/// <typeparam name="U"></typeparam>
|
525
|
/// <param name="items"></param>
|
526
|
public void RemoveAll<U>(System.Collections.Generic.IEnumerable<U> items) where U : T { throw new FixedSizeCollectionException(); }
|
527
|
|
528
|
/// <summary>
|
529
|
///
|
530
|
/// </summary>
|
531
|
public void Clear() { throw new FixedSizeCollectionException(); }
|
532
|
|
533
|
/// <summary>
|
534
|
///
|
535
|
/// </summary>
|
536
|
/// <typeparam name="U"></typeparam>
|
537
|
/// <param name="items"></param>
|
538
|
public void RetainAll<U>(System.Collections.Generic.IEnumerable<U> items) where U : T { throw new FixedSizeCollectionException(); }
|
539
|
|
540
|
#endregion
|
541
|
|
542
|
#region IExtensible<T> Members
|
543
|
|
544
|
/// <summary>
|
545
|
///
|
546
|
/// </summary>
|
547
|
/// <value></value>
|
548
|
public bool IsReadOnly { get { return true; } }
|
549
|
|
550
|
/// <summary>
|
551
|
///
|
552
|
/// </summary>
|
553
|
/// <value></value>
|
554
|
public bool AllowsDuplicates
|
555
|
{
|
556
|
get { return true; }
|
557
|
}
|
558
|
|
559
|
/// <summary>
|
560
|
///
|
561
|
/// </summary>
|
562
|
/// <value></value>
|
563
|
public SCG.IEqualityComparer<T> EqualityComparer { get { return innerlist.EqualityComparer; } }
|
564
|
|
565
|
/// <summary>
|
566
|
///
|
567
|
/// </summary>
|
568
|
/// <value></value>
|
569
|
public bool DuplicatesByCounting
|
570
|
{
|
571
|
get { return false; }
|
572
|
}
|
573
|
|
574
|
/// <summary>
|
575
|
///
|
576
|
/// </summary>
|
577
|
/// <param name="item"></param>
|
578
|
/// <returns></returns>
|
579
|
public bool Add(T item)
|
580
|
{
|
581
|
throw new FixedSizeCollectionException();
|
582
|
}
|
583
|
|
584
|
/// <summary>
|
585
|
///
|
586
|
/// </summary>
|
587
|
/// <typeparam name="U"></typeparam>
|
588
|
/// <param name="items"></param>
|
589
|
public void AddAll<U>(System.Collections.Generic.IEnumerable<U> items) where U : T
|
590
|
{
|
591
|
throw new FixedSizeCollectionException();
|
592
|
}
|
593
|
|
594
|
/// <summary>
|
595
|
///
|
596
|
/// </summary>
|
597
|
/// <returns></returns>
|
598
|
public bool Check()
|
599
|
{
|
600
|
return innerlist.Check() && (underlying == null || underlying.innerlist == innerlist.Underlying);
|
601
|
}
|
602
|
|
603
|
#endregion
|
604
|
|
605
|
#region ICollectionValue<T> Members
|
606
|
/// <summary>
|
607
|
/// No listeners may be installed
|
608
|
/// </summary>
|
609
|
/// <value>0</value>
|
610
|
public virtual EventTypeEnum ListenableEvents { get { return 0; } }
|
611
|
|
612
|
/// <summary>
|
613
|
/// No listeners ever installed
|
614
|
/// </summary>
|
615
|
/// <value>0</value>
|
616
|
public virtual EventTypeEnum ActiveEvents { get { return 0; } }
|
617
|
|
618
|
/// <summary>
|
619
|
///
|
620
|
/// </summary>
|
621
|
/// <value></value>
|
622
|
public event CollectionChangedHandler<T> CollectionChanged
|
623
|
{
|
624
|
add { throw new UnlistenableEventException(); }
|
625
|
remove { throw new UnlistenableEventException(); }
|
626
|
}
|
627
|
|
628
|
/// <summary>
|
629
|
///
|
630
|
/// </summary>
|
631
|
/// <value></value>
|
632
|
public event CollectionClearedHandler<T> CollectionCleared
|
633
|
{
|
634
|
add { throw new UnlistenableEventException(); }
|
635
|
remove { throw new UnlistenableEventException(); }
|
636
|
}
|
637
|
|
638
|
/// <summary>
|
639
|
///
|
640
|
/// </summary>
|
641
|
/// <value></value>
|
642
|
public event ItemsAddedHandler<T> ItemsAdded
|
643
|
{
|
644
|
add { throw new UnlistenableEventException(); }
|
645
|
remove { throw new UnlistenableEventException(); }
|
646
|
}
|
647
|
|
648
|
/// <summary>
|
649
|
///
|
650
|
/// </summary>
|
651
|
/// <value></value>
|
652
|
public event ItemInsertedHandler<T> ItemInserted
|
653
|
{
|
654
|
add { throw new UnlistenableEventException(); }
|
655
|
remove { throw new UnlistenableEventException(); }
|
656
|
}
|
657
|
|
658
|
/// <summary>
|
659
|
///
|
660
|
/// </summary>
|
661
|
/// <value></value>
|
662
|
public event ItemsRemovedHandler<T> ItemsRemoved
|
663
|
{
|
664
|
add { throw new UnlistenableEventException(); }
|
665
|
remove { throw new UnlistenableEventException(); }
|
666
|
}
|
667
|
|
668
|
/// <summary>
|
669
|
///
|
670
|
/// </summary>
|
671
|
/// <value></value>
|
672
|
public event ItemRemovedAtHandler<T> ItemRemovedAt
|
673
|
{
|
674
|
add { throw new UnlistenableEventException(); }
|
675
|
remove { throw new UnlistenableEventException(); }
|
676
|
}
|
677
|
|
678
|
/// <summary>
|
679
|
///
|
680
|
/// </summary>
|
681
|
/// <value></value>
|
682
|
public bool IsEmpty { get { return innerlist.IsEmpty; } }
|
683
|
|
684
|
/// <summary>
|
685
|
///
|
686
|
/// </summary>
|
687
|
/// <value></value>
|
688
|
public int Count { get { return innerlist.Count; } }
|
689
|
|
690
|
/// <summary>
|
691
|
///
|
692
|
/// </summary>
|
693
|
/// <value></value>
|
694
|
public Speed CountSpeed { get { return innerlist.CountSpeed; } }
|
695
|
|
696
|
/// <summary>
|
697
|
///
|
698
|
/// </summary>
|
699
|
/// <param name="array"></param>
|
700
|
/// <param name="index"></param>
|
701
|
public void CopyTo(T[] array, int index) { innerlist.CopyTo(array, index); }
|
702
|
|
703
|
/// <summary>
|
704
|
///
|
705
|
/// </summary>
|
706
|
/// <returns></returns>
|
707
|
public T[] ToArray() { return innerlist.ToArray(); }
|
708
|
|
709
|
/// <summary>
|
710
|
///
|
711
|
/// </summary>
|
712
|
/// <param name="action"></param>
|
713
|
public void Apply(Act<T> action) { innerlist.Apply(action); }
|
714
|
|
715
|
/// <summary>
|
716
|
///
|
717
|
/// </summary>
|
718
|
/// <param name="predicate"></param>
|
719
|
/// <returns></returns>
|
720
|
public bool Exists(Fun<T, bool> predicate) { return innerlist.Exists(predicate); }
|
721
|
|
722
|
/// <summary>
|
723
|
///
|
724
|
/// </summary>
|
725
|
/// <param name="predicate"></param>
|
726
|
/// <param name="item"></param>
|
727
|
/// <returns></returns>
|
728
|
public bool Find(Fun<T, bool> predicate, out T item) { return innerlist.Find(predicate, out item); }
|
729
|
|
730
|
/// <summary>
|
731
|
///
|
732
|
/// </summary>
|
733
|
/// <param name="predicate"></param>
|
734
|
/// <returns></returns>
|
735
|
public bool All(Fun<T, bool> predicate) { return innerlist.All(predicate); }
|
736
|
|
737
|
/// <summary>
|
738
|
///
|
739
|
/// </summary>
|
740
|
/// <returns></returns>
|
741
|
public T Choose() { return innerlist.Choose(); }
|
742
|
|
743
|
/// <summary>
|
744
|
///
|
745
|
/// </summary>
|
746
|
/// <param name="filter"></param>
|
747
|
/// <returns></returns>
|
748
|
public SCG.IEnumerable<T> Filter(Fun<T, bool> filter) { return innerlist.Filter(filter); }
|
749
|
|
750
|
#endregion
|
751
|
|
752
|
#region IEnumerable<T> Members
|
753
|
|
754
|
/// <summary>
|
755
|
///
|
756
|
/// </summary>
|
757
|
/// <returns></returns>
|
758
|
public SCG.IEnumerator<T> GetEnumerator() { return innerlist.GetEnumerator(); }
|
759
|
#endregion
|
760
|
|
761
|
#region IShowable Members
|
762
|
|
763
|
/// <summary>
|
764
|
///
|
765
|
/// </summary>
|
766
|
/// <param name="stringbuilder"></param>
|
767
|
/// <param name="rest"></param>
|
768
|
/// <param name="formatProvider"></param>
|
769
|
/// <returns></returns>
|
770
|
public bool Show(StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider)
|
771
|
{ return innerlist.Show(stringbuilder, ref rest, formatProvider); }
|
772
|
|
773
|
#endregion
|
774
|
|
775
|
#region IFormattable Members
|
776
|
|
777
|
/// <summary>
|
778
|
///
|
779
|
/// </summary>
|
780
|
/// <returns></returns>
|
781
|
public override string ToString() { return innerlist.ToString(); }
|
782
|
|
783
|
|
784
|
/// <summary>
|
785
|
///
|
786
|
/// </summary>
|
787
|
/// <param name="format"></param>
|
788
|
/// <param name="formatProvider"></param>
|
789
|
/// <returns></returns>
|
790
|
public virtual string ToString(string format, IFormatProvider formatProvider) { return innerlist.ToString(format, formatProvider); }
|
791
|
|
792
|
#endregion
|
793
|
|
794
|
#region IDirectedCollectionValue<T> Members
|
795
|
|
796
|
/// <summary>
|
797
|
///
|
798
|
/// </summary>
|
799
|
/// <returns></returns>
|
800
|
public IDirectedCollectionValue<T> Backwards() { return innerlist.Backwards(); }
|
801
|
|
802
|
/// <summary>
|
803
|
///
|
804
|
/// </summary>
|
805
|
/// <param name="predicate"></param>
|
806
|
/// <param name="item"></param>
|
807
|
/// <returns></returns>
|
808
|
public bool FindLast(Fun<T, bool> predicate, out T item) { return innerlist.FindLast(predicate, out item); }
|
809
|
|
810
|
#endregion
|
811
|
|
812
|
#region IDirectedEnumerable<T> Members
|
813
|
|
814
|
IDirectedEnumerable<T> IDirectedEnumerable<T>.Backwards() { return Backwards(); }
|
815
|
|
816
|
/// <summary>
|
817
|
///
|
818
|
/// </summary>
|
819
|
/// <value></value>
|
820
|
public EnumerationDirection Direction { get { return EnumerationDirection.Forwards; } }
|
821
|
|
822
|
#endregion
|
823
|
|
824
|
#region IDisposable Members
|
825
|
|
826
|
/// <summary>
|
827
|
/// Dispose this if a view else operation is illegal
|
828
|
/// </summary>
|
829
|
/// <exception cref="FixedSizeCollectionException">If not a view</exception>
|
830
|
public void Dispose()
|
831
|
{
|
832
|
if (underlying == null)
|
833
|
throw new FixedSizeCollectionException();
|
834
|
else
|
835
|
innerlist.Dispose();
|
836
|
}
|
837
|
|
838
|
#endregion
|
839
|
|
840
|
#region ICloneable Members
|
841
|
|
842
|
/// <summary>
|
843
|
/// Make a shallow copy of this WrappedArray.
|
844
|
///
|
845
|
///
|
846
|
/// </summary>
|
847
|
/// <returns></returns>
|
848
|
public virtual object Clone()
|
849
|
{
|
850
|
return new WrappedArray<T>(innerlist.ToArray());
|
851
|
}
|
852
|
|
853
|
#endregion
|
854
|
|
855
|
#region System.Collections.Generic.IList<T> Members
|
856
|
|
857
|
void System.Collections.Generic.IList<T>.RemoveAt(int index)
|
858
|
{
|
859
|
throw new FixedSizeCollectionException();
|
860
|
}
|
861
|
|
862
|
void System.Collections.Generic.ICollection<T>.Add(T item)
|
863
|
{
|
864
|
throw new FixedSizeCollectionException();
|
865
|
}
|
866
|
|
867
|
#endregion
|
868
|
|
869
|
#region System.Collections.ICollection Members
|
870
|
|
871
|
bool System.Collections.ICollection.IsSynchronized
|
872
|
{
|
873
|
get { return false; }
|
874
|
}
|
875
|
|
876
|
[Obsolete]
|
877
|
Object System.Collections.ICollection.SyncRoot
|
878
|
{
|
879
|
get { return ((System.Collections.IList)innerlist).SyncRoot; }
|
880
|
}
|
881
|
|
882
|
void System.Collections.ICollection.CopyTo(Array arr, int index)
|
883
|
{
|
884
|
if (index < 0 || index + Count > arr.Length)
|
885
|
throw new ArgumentOutOfRangeException();
|
886
|
|
887
|
foreach (T item in this)
|
888
|
arr.SetValue(item, index++);
|
889
|
}
|
890
|
|
891
|
#endregion
|
892
|
|
893
|
#region System.Collections.IList Members
|
894
|
|
895
|
Object System.Collections.IList.this[int index]
|
896
|
{
|
897
|
get { return this[index]; }
|
898
|
set { this[index] = (T)value; }
|
899
|
}
|
900
|
|
901
|
int System.Collections.IList.Add(Object o)
|
902
|
{
|
903
|
bool added = Add((T)o);
|
904
|
// What position to report if item not added? SC.IList.Add doesn't say
|
905
|
return added ? Count - 1 : -1;
|
906
|
}
|
907
|
|
908
|
bool System.Collections.IList.Contains(Object o)
|
909
|
{
|
910
|
return Contains((T)o);
|
911
|
}
|
912
|
|
913
|
int System.Collections.IList.IndexOf(Object o)
|
914
|
{
|
915
|
return Math.Max(-1, IndexOf((T)o));
|
916
|
}
|
917
|
|
918
|
void System.Collections.IList.Insert(int index, Object o)
|
919
|
{
|
920
|
Insert(index, (T)o);
|
921
|
}
|
922
|
|
923
|
void System.Collections.IList.Remove(Object o)
|
924
|
{
|
925
|
Remove((T)o);
|
926
|
}
|
927
|
|
928
|
void System.Collections.IList.RemoveAt(int index)
|
929
|
{
|
930
|
RemoveAt(index);
|
931
|
}
|
932
|
|
933
|
#endregion
|
934
|
|
935
|
#region IEnumerable Members
|
936
|
|
937
|
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
938
|
{
|
939
|
throw new Exception("The method or operation is not implemented.");
|
940
|
}
|
941
|
|
942
|
#endregion
|
943
|
}
|
944
|
}
|