source: trunk/CrypPlugins/WorkspaceManager/View/VisualComponents/CryptoLineView/PowerCollections/ListBase.cs @ 1927

Last change on this file since 1927 was 1927, checked in by matkovic, 11 years ago

-added PowerCollection library
-added QuadTree
-improved path finding performance

File size: 31.3 KB
Line 
1//******************************
2// Written by Peter Golde
3// Copyright (c) 2004-2007, Wintellect
4//
5// Use and restribution of this code is subject to the license agreement
6// contained in the file "License.txt" accompanying this file.
7//******************************
8
9using System;
10using System.Collections;
11using System.Collections.Generic;
12
13namespace Wintellect.PowerCollections
14{
15    /// <summary>
16    /// ListBase is an abstract class that can be used as a base class for a read-write collection that needs
17    /// to implement the generic IList&lt;T&gt; and non-generic IList collections. The derived class needs
18    /// to override the following methods: Count, Clear, Insert, RemoveAt, and the indexer. The implementation
19    /// of all the other methods in IList&lt;T&gt; and IList are handled by ListBase.
20    /// </summary>
21    /// <typeparam name="T"></typeparam>
22    [Serializable]
23    public abstract class ListBase<T> : CollectionBase<T>, IList<T>, IList
24    {
25        /// <summary>
26        /// The property must be overridden by the derived class to return the number of
27        /// items in the list.
28        /// </summary>
29        /// <value>The number of items in the list.</value>
30        public abstract override int Count { get;} 
31
32        /// <summary>
33        /// This method must be overridden by the derived class to empty the list
34        /// of all items.
35        /// </summary>
36        public abstract override void Clear();
37
38        /// <summary>
39        /// The indexer must be overridden by the derived class to get and set
40        /// values of the list at a particular index.
41        /// </summary>
42        /// <param name="index">The index in the list to get or set an item at. The
43        /// first item in the list has index 0, and the last has index Count-1.</param>
44        /// <returns>The item at the given index.</returns>
45        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is
46        /// less than zero or greater than or equal to Count.</exception>
47        public abstract T this[int index]
48        {
49            get;
50            set;
51        }
52
53        /// <summary>
54        /// This method must be overridden by the derived class to insert a new
55        /// item at the given index.
56        /// </summary>
57        /// <param name="index">The index in the list to insert the item at. After the
58        /// insertion, the inserted item is located at this index. The
59        /// first item in the list has index 0.</param>
60        /// <param name="item">The item to insert at the given index.</param>
61        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is
62        /// less than zero or greater than Count.</exception>
63        public abstract void Insert(int index, T item);
64
65        /// <summary>
66        /// This method must be overridden by the derived class to remove the
67        /// item at the given index.
68        /// </summary>
69        /// <param name="index">The index in the list to remove the item at. The
70        /// first item in the list has index 0.</param>
71        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is
72        /// less than zero or greater than or equal to Count.</exception>
73        public abstract void RemoveAt(int index);
74
75        /// <summary>
76        /// Enumerates all of the items in the list, in order. The item at index 0
77        /// is enumerated first, then the item at index 1, and so on.
78        /// </summary>
79        /// <remarks>The enumerator does not check for changes made
80        /// to the structure of the list. Thus, changes to the list during
81        /// enumeration may cause incorrect enumeration or out of range
82        /// exceptions. Consider overriding this method and adding checks
83        /// for structural changes.</remarks>
84        /// <returns>An IEnumerator&lt;T&gt; that enumerates all the
85        /// items in the list.</returns>
86        public override IEnumerator<T> GetEnumerator()
87        {
88            int count = Count;
89            for (int i = 0; i < count; ++i) {
90                yield return this[i];
91            }
92        }
93
94        /// <summary>
95        /// Determines if the list contains any item that compares equal to <paramref name="item"/>.
96        /// The implementation simply checks whether IndexOf(item) returns a non-negative value.
97        /// </summary>
98        /// <remarks>Equality in the list is determined by the default sense of
99        /// equality for T. If T implements IComparable&lt;T&gt;, the
100        /// Equals method of that interface is used to determine equality. Otherwise,
101        /// Object.Equals is used to determine equality.</remarks>
102        /// <param name="item">The item to search for.</param>
103        /// <returns>True if the list contains an item that compares equal to <paramref name="item"/>.</returns>
104        public override bool Contains(T item)
105        {
106            return (IndexOf(item) >= 0);
107        }
108
109        /// <summary>
110        /// Adds an item to the end of the list. This method is equivalent to calling:
111        /// <code>Insert(Count, item)</code>
112        /// </summary>
113        /// <param name="item">The item to add to the list.</param>
114        public override void Add(T item)
115        {
116            Insert(Count, item);
117        }
118
119        /// <summary>
120        /// Searches the list for the first item that compares equal to <paramref name="item"/>.
121        /// If one is found, it is removed. Otherwise, the list is unchanged.
122        /// </summary>
123        /// <remarks>Equality in the list is determined by the default sense of
124        /// equality for T. If T implements IComparable&lt;T&gt;, the
125        /// Equals method of that interface is used to determine equality. Otherwise,
126        /// Object.Equals is used to determine equality.</remarks>
127        /// <param name="item">The item to remove from the list.</param>
128        /// <returns>True if an item was found and removed that compared equal to
129        /// <paramref name="item"/>. False if no such item was in the list.</returns>
130        public override bool Remove(T item)
131        {
132            int index = IndexOf(item);
133            if (index >= 0) {
134                RemoveAt(index);
135                return true;
136            }
137            else {
138                return false;
139            }
140        }
141
142        /// <summary>
143        /// Copies all the items in the list, in order, to <paramref name="array"/>,
144        /// starting at index 0.
145        /// </summary>
146        /// <param name="array">The array to copy to. This array must have a size
147        /// that is greater than or equal to Count.</param>
148        public virtual void CopyTo(T[] array)
149        {
150            this.CopyTo(array, 0);
151        }
152
153        /// <summary>
154        /// Copies a range of elements from the list to <paramref name="array"/>,
155        /// starting at <paramref name="arrayIndex"/>.
156        /// </summary>
157        /// <param name="index">The starting index in the source list of the range to copy.</param>
158        /// <param name="array">The array to copy to. This array must have a size
159        /// that is greater than or equal to Count + arrayIndex.</param>
160        /// <param name="arrayIndex">The starting index in <paramref name="array"/>
161        /// to copy to.</param>
162        /// <param name="count">The number of items to copy.</param>
163        public virtual void CopyTo(int index, T[] array, int arrayIndex, int count)
164        {
165            Range(index, count).CopyTo(array, arrayIndex);
166        }
167
168        /// <summary>
169        /// Provides a read-only view of this list. The returned IList&lt;T&gt; provides
170        /// a view of the list that prevents modifications to the list. Use the method to provide
171        /// access to the list without allowing changes. Since the returned object is just a view,
172        /// changes to the list will be reflected in the view.
173        /// </summary>
174        /// <returns>An IList&lt;T&gt; that provides read-only access to the list.</returns>
175        public virtual new IList<T> AsReadOnly()
176        {
177            return Algorithms.ReadOnly(this);
178        }
179
180        /// <summary>
181        /// Finds the first item in the list that satisfies the condition
182        /// defined by <paramref name="predicate"/>. If no item matches the condition, than
183        /// the default value for T (null or all-zero) is returned.
184        /// </summary>
185        /// <remarks>If the default value for T (null or all-zero) matches the condition defined by <paramref name="predicate"/>,
186        /// and the list might contain the default value, then it is impossible to distinguish the different between finding
187        /// the default value and not finding any item. To distinguish these cases, use <see cref="TryFind"/>.</remarks>
188        /// <param name="predicate">A delegate that defined the condition to check for.</param>
189        /// <returns>The first item that satisfies the condition <paramref name="predicate"/>. If no item satisfies that
190        /// condition, the default value for T is returned.</returns>
191        /// <seealso cref="TryFind"/>
192        public virtual T Find(Predicate<T> predicate)
193        {
194            return Algorithms.FindFirstWhere(this, predicate);
195        }
196
197        /// <summary>
198        /// Finds the first item in the list that satisfies the condition
199        /// defined by <paramref name="predicate"/>.
200        /// </summary>
201        /// <param name="predicate">A delegate that defines the condition to check for.</param>
202        /// <param name="foundItem">If true is returned, this parameter receives the first item in the list
203        /// that satifies the condition defined by <paramref name="predicate"/>.</param>
204        /// <returns>True if an item that  satisfies the condition <paramref name="predicate"/> was found. False
205        /// if no item in the list satisfies that condition.</returns>
206        public virtual bool TryFind(Predicate<T> predicate, out T foundItem)
207        {
208            return Algorithms.TryFindFirstWhere(this, predicate, out foundItem);
209        }
210
211        /// <summary>
212        /// Finds the last item in the list that satisfies the condition
213        /// defined by <paramref name="predicate"/>. If no item matches the condition, than
214        /// the default value for T (null or all-zero) is returned.
215        /// </summary>
216        /// <remarks>If the default value for T (null or all-zero) matches the condition defined by <paramref name="predicate"/>,
217        /// and the list might contain the default value, then it is impossible to distinguish the different between finding
218        /// the default value and not finding any item. To distinguish these cases, use <see cref="TryFindLast"/>.</remarks>
219        /// <param name="predicate">A delegate that defined the condition to check for.</param>
220        /// <returns>The last item that satisfies the condition <paramref name="predicate"/>. If no item satisfies that
221        /// condition, the default value for T is returned.</returns>
222        /// <seealso cref="TryFindLast"/>
223        public virtual T FindLast(Predicate<T> predicate)
224        {
225            return Algorithms.FindLastWhere(this, predicate);
226        }
227
228        /// <summary>
229        /// Finds the last item in the list that satisfies the condition
230        /// defined by <paramref name="predicate"/>.
231        /// </summary>
232        /// <param name="predicate">A delegate that defines the condition to check for.</param>
233        /// <param name="foundItem">If true is returned, this parameter receives the last item in the list
234        /// that satifies the condition defined by <paramref name="predicate"/>.</param>
235        /// <returns>True if an item that  satisfies the condition <paramref name="predicate"/> was found. False
236        /// if no item in the list satisfies that condition.</returns>
237        public virtual bool TryFindLast(Predicate<T> predicate, out T foundItem)
238        {
239            return Algorithms.TryFindLastWhere(this, predicate, out foundItem);
240        }
241
242        /// <summary>
243        /// Finds the index of the first item in the list that satisfies the condition
244        /// defined by <paramref name="predicate"/>. If no item matches the condition, -1 is returned.
245        /// </summary>
246        /// <param name="predicate">A delegate that defined the condition to check for.</param>
247        /// <returns>The index of the first item that satisfies the condition <paramref name="predicate"/>. If no item satisfies that
248        /// condition, -1 is returned.</returns>
249        public virtual int FindIndex(Predicate<T> predicate)
250        {
251            return Algorithms.FindFirstIndexWhere(this, predicate);
252        }
253
254        /// <summary>
255        /// Finds the index of the first item, in the range of items extending from <paramref name="index"/> to the end, that satisfies the condition
256        /// defined by <paramref name="predicate"/>. If no item matches the condition, -1 is returned.
257        /// </summary>
258        /// <param name="predicate">A delegate that defined the condition to check for.</param>
259        /// <param name="index">The starting index of the range to check.</param>
260        /// <returns>The index of the first item in the given range that satisfies the condition <paramref name="predicate"/>. If no item satisfies that
261        /// condition, -1 is returned.</returns>
262        public virtual int FindIndex(int index, Predicate<T> predicate)
263        {
264            int foundIndex = Algorithms.FindFirstIndexWhere(Range(index, Count - index), predicate);
265            if (foundIndex < 0)
266                return -1;
267            else
268                return foundIndex + index;
269        }
270
271        /// <summary>
272        /// Finds the index of the first item, in the range of <paramref name="count"/> items starting from <paramref name="index"/>, that satisfies the condition
273        /// defined by <paramref name="predicate"/>. If no item matches the condition, -1 is returned.
274        /// </summary>
275        /// <param name="predicate">A delegate that defined the condition to check for.</param>
276        /// <param name="index">The starting index of the range to check.</param>
277        /// <param name="count">The number of items in range to check.</param>
278        /// <returns>The index of the first item in the given range that satisfies the condition <paramref name="predicate"/>. If no item satisfies that
279        /// condition, -1 is returned.</returns>
280        public virtual int FindIndex(int index, int count, Predicate<T> predicate)
281        {
282            int foundIndex = Algorithms.FindFirstIndexWhere(Range(index, count), predicate);
283            if (foundIndex < 0)
284                return -1;
285            else
286                return foundIndex + index;
287        }
288
289        /// <summary>
290        /// Finds the index of the last item in the list that satisfies the condition
291        /// defined by <paramref name="predicate"/>. If no item matches the condition, -1 is returned.
292        /// </summary>
293        /// <param name="predicate">A delegate that defined the condition to check for.</param>
294        /// <returns>The index of the last item that satisfies the condition <paramref name="predicate"/>. If no item satisfies that
295        /// condition, -1 is returned.</returns>
296        public virtual int FindLastIndex(Predicate<T> predicate)
297        {
298            return Algorithms.FindLastIndexWhere(this, predicate);
299        }
300
301        /// <summary>
302        /// Finds the index of the last item, in the range of items extending from the beginning
303        /// of the list to <paramref name="index"/>, that satisfies the condition
304        /// defined by <paramref name="predicate"/>. If no item matches the condition, -1 is returned.
305        /// </summary>
306        /// <param name="predicate">A delegate that defined the condition to check for.</param>
307        /// <param name="index">The ending index of the range to check.</param>
308        /// <returns>The index of the last item in the given range that satisfies the condition <paramref name="predicate"/>. If no item satisfies that
309        /// condition, -1 is returned.</returns>
310        public virtual int FindLastIndex(int index, Predicate<T> predicate)
311        {
312            return Algorithms.FindLastIndexWhere(Range(0, index + 1), predicate);
313        }
314
315        /// <summary>
316        /// Finds the index of the last item, in the range of <paramref name="count"/> items ending at <paramref name="index"/>, that satisfies the condition
317        /// defined by <paramref name="predicate"/>. If no item matches the condition, -1 is returned.
318        /// </summary>
319        /// <param name="predicate">A delegate that defined the condition to check for.</param>
320        /// <param name="index">The ending index of the range to check.</param>
321        /// <param name="count">The number of items in range to check.</param>
322        /// <returns>The index of the last item in the given range that satisfies the condition <paramref name="predicate"/>. If no item satisfies that
323        /// condition, -1 is returned.</returns>
324        public virtual int FindLastIndex(int index, int count, Predicate<T> predicate)
325        {
326            int foundIndex = Algorithms.FindLastIndexWhere(Range(index - count + 1, count), predicate);
327
328            if (foundIndex >= 0)
329                return foundIndex + index - count + 1;
330            else
331                return -1;
332        }
333
334        /// <summary>
335        /// Finds the index of the first item in the list that is equal to <paramref name="item"/>.
336        /// </summary>
337        /// <remarks>The default implementation of equality for type T is used in the search. This is the
338        /// equality defined by IComparable&lt;T&gt; or object.Equals.</remarks>
339        /// <param name="item">The item to search fror.</param>
340        /// <returns>The index of the first item in the list that that is equal to <paramref name="item"/>.  If no item is equal
341        /// to <paramref name="item"/>, -1 is returned.</returns>
342        public virtual int IndexOf(T item)
343        {
344            return Algorithms.FirstIndexOf(this, item, EqualityComparer<T>.Default);
345        }
346
347        /// <summary>
348        /// Finds the index of the first item, in the range of items extending from <paramref name="index"/> to the end, 
349        /// that is equal to <paramref name="item"/>.
350        /// </summary>
351        /// <remarks>The default implementation of equality for type T is used in the search. This is the
352        /// equality defined by IComparable&lt;T&gt; or object.Equals.</remarks>
353        /// <param name="item">The item to search fror.</param>
354        /// <param name="index">The starting index of the range to check.</param>
355        /// <returns>The index of the first item in the given range that that is equal to <paramref name="item"/>.  If no item is equal
356        /// to <paramref name="item"/>, -1 is returned.</returns>
357        public virtual int IndexOf(T item, int index)
358        {
359            int foundIndex = Algorithms.FirstIndexOf(Range(index, Count - index), item, EqualityComparer<T>.Default);
360
361            if (foundIndex >= 0)
362                return foundIndex + index;
363            else
364                return -1;
365        }
366
367        /// <summary>
368        /// Finds the index of the first item, in the range of <paramref name="count"/> items starting from <paramref name="index"/>, 
369        /// that is equal to <paramref name="item"/>.
370        /// </summary>
371        /// <remarks>The default implementation of equality for type T is used in the search. This is the
372        /// equality defined by IComparable&lt;T&gt; or object.Equals.</remarks>
373        /// <param name="item">The item to search fror.</param>
374        /// <param name="index">The starting index of the range to check.</param>
375        /// <param name="count">The number of items in range to check.</param>
376        /// <returns>The index of the first item in the given range that that is equal to <paramref name="item"/>.  If no item is equal
377        /// to <paramref name="item"/>, -1 is returned.</returns>
378        public virtual int IndexOf(T item, int index, int count)
379        {
380            int foundIndex = Algorithms.FirstIndexOf(Range(index, count), item, EqualityComparer<T>.Default);
381
382            if (foundIndex >= 0)
383                return foundIndex + index;
384            else
385                return -1;
386        }
387
388        /// <summary>
389        /// Finds the index of the last item in the list that is equal to <paramref name="item"/>.
390        /// </summary>
391        /// <remarks>The default implementation of equality for type T is used in the search. This is the
392        /// equality defined by IComparable&lt;T&gt; or object.Equals.</remarks>
393        /// <param name="item">The item to search fror.</param>
394        /// <returns>The index of the last item in the list that that is equal to <paramref name="item"/>.  If no item is equal
395        /// to <paramref name="item"/>, -1 is returned.</returns>
396        public virtual int LastIndexOf(T item)
397        {
398            return Algorithms.LastIndexOf(this, item, EqualityComparer<T>.Default);
399        }
400
401        /// <summary>
402        /// Finds the index of the last item, in the range of items extending from the beginning
403        /// of the list to <paramref name="index"/>, that is equal to <paramref name="item"/>.
404        /// </summary>
405        /// <remarks>The default implementation of equality for type T is used in the search. This is the
406        /// equality defined by IComparable&lt;T&gt; or object.Equals.</remarks>
407        /// <param name="item">The item to search fror.</param>
408        /// <param name="index">The ending index of the range to check.</param>
409        /// <returns>The index of the last item in the given range that that is equal to <paramref name="item"/>.  If no item is equal
410        /// to <paramref name="item"/>, -1 is returned.</returns>
411        public virtual int LastIndexOf(T item, int index)
412        {
413            int foundIndex = Algorithms.LastIndexOf(Range(0, index + 1), item, EqualityComparer<T>.Default);
414
415            return foundIndex;
416        }
417
418        /// <summary>
419        /// Finds the index of the last item, in the range of <paramref name="count"/> items ending at <paramref name="index"/>,
420        /// that is equal to <paramref name="item"/>.
421        /// </summary>
422        /// <remarks>The default implementation of equality for type T is used in the search. This is the
423        /// equality defined by IComparable&lt;T&gt; or object.Equals.</remarks>
424        /// <param name="item">The item to search for.</param>
425        /// <param name="index">The ending index of the range to check.</param>
426        /// <param name="count">The number of items in range to check.</param>
427        /// <returns>The index of the last item in the given range that that is equal to <paramref name="item"/>.  If no item is equal
428        /// to <paramref name="item"/>, -1 is returned.</returns>
429        public virtual int LastIndexOf(T item, int index, int count)
430        {
431            int foundIndex = Algorithms.LastIndexOf(Range(index - count + 1, count), item, EqualityComparer<T>.Default);
432
433            if (foundIndex >= 0)
434                return foundIndex + index - count + 1;
435            else
436                return -1;
437        }
438
439        /// <summary>
440        /// Returns a view onto a sub-range of this list. Items are not copied; the
441        /// returned IList&lt;T&gt; is simply a different view onto the same underlying items. Changes to this list
442        /// are reflected in the view, and vice versa. Insertions and deletions in the view change the size of the
443        /// view, but insertions and deletions in the underlying list do not.
444        /// </summary>
445        /// <remarks>
446        /// <para>This method can be used to apply an algorithm to a portion of a list. For example:</para>
447        /// <code>Algorithms.ReverseInPlace(deque.Range(3, 6))</code>
448        /// will reverse the 6 items beginning at index 3.</remarks>
449        /// <param name="start">The starting index of the view.</param>
450        /// <param name="count">The number of items in the view.</param>
451        /// <returns>A list that is a view onto the given sub-part of this list. </returns>
452        /// <exception cref="ArgumentOutOfRangeException"><paramref name="start"/> or <paramref name="count"/> is negative.</exception>
453        /// <exception cref="ArgumentOutOfRangeException"><paramref name="start"/> + <paramref name="count"/> is greater than the
454        /// size of the list.</exception>
455        public virtual IList<T> Range(int start, int count)
456        {
457            return Algorithms.Range(this, start, count);
458        }
459
460        /// <summary>
461        /// Convert the given parameter to T. Throw an ArgumentException
462        /// if it isn't.
463        /// </summary>
464        /// <param name="name">parameter name</param>
465        /// <param name="value">parameter value</param>
466        private static T ConvertToItemType(string name, object value)
467        {
468            try {
469                return (T)value;
470            }
471            catch (InvalidCastException) {
472                throw new ArgumentException(string.Format(Strings.WrongType, value, typeof(T)), name);
473            }
474        }
475
476        /// <summary>
477        /// Adds an item to the end of the list. This method is equivalent to calling:
478        /// <code>Insert(Count, item)</code>
479        /// </summary>
480        /// <param name="value">The item to add to the list.</param>
481        /// <exception cref="ArgumentException"><paramref name="value"/> cannot be converted to T.</exception>
482        int IList.Add(object value)
483        {
484            int count = Count;
485            Insert(count, ConvertToItemType("value", value));
486            return count;
487        }
488
489        /// <summary>
490        /// Removes all the items from the list, resulting in an empty list.
491        /// </summary>
492        void IList.Clear()
493        {
494            Clear();
495        }
496
497        /// <summary>
498        /// Determines if the list contains any item that compares equal to <paramref name="value"/>.
499        /// </summary>
500        /// <remarks>Equality in the list is determined by the default sense of
501        /// equality for T. If T implements IComparable&lt;T&gt;, the
502        /// Equals method of that interface is used to determine equality. Otherwise,
503        /// Object.Equals is used to determine equality.</remarks>
504        /// <param name="value">The item to search for.</param>
505        bool IList.Contains(object value)
506        {
507            if (value is T || value == null)
508                return Contains((T)value);
509            else
510                return false;
511        }
512
513        /// <summary>
514        /// Find the first occurrence of an item equal to <paramref name="value"/>
515        /// in the list, and returns the index of that item.
516        /// </summary>
517        /// <remarks>Equality in the list is determined by the default sense of
518        /// equality for T. If T implements IComparable&lt;T&gt;, the
519        /// Equals method of that interface is used to determine equality. Otherwise,
520        /// Object.Equals is used to determine equality.</remarks>
521        /// <param name="value">The item to search for.</param>
522        /// <returns>The index of <paramref name="value"/>, or -1 if no item in the
523        /// list compares equal to <paramref name="value"/>.</returns>
524        int IList.IndexOf(object value)
525        {
526            if (value is T || value == null)
527                return IndexOf((T)value);
528            else
529                return -1;
530        }
531
532        /// <summary>
533        /// Insert a new
534        /// item at the given index.
535        /// </summary>
536        /// <param name="index">The index in the list to insert the item at. After the
537        /// insertion, the inserted item is located at this index. The
538        /// first item in the list has index 0.</param>
539        /// <param name="value">The item to insert at the given index.</param>
540        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is
541        /// less than zero or greater than Count.</exception>
542        /// <exception cref="ArgumentException"><paramref name="value"/> cannot be converted to T.</exception>
543        void IList.Insert(int index, object value)
544        {
545            Insert(index, ConvertToItemType("value", value));
546        }
547
548        /// <summary>
549        /// Returns whether the list is a fixed size. This implementation always returns false.
550        /// </summary>
551        /// <value>Alway false, indicating that the list is not fixed size.</value>
552        bool IList.IsFixedSize
553        {
554            get { return false; }
555        }
556
557        /// <summary>
558        /// Returns whether the list is read only. This implementation returns the value
559        /// from ICollection&lt;T&gt;.IsReadOnly, which is by default, false.
560        /// </summary>
561        /// <value>By default, false, indicating that the list is not read only.</value>
562        bool IList.IsReadOnly
563        {
564            get { return ((ICollection<T>)this).IsReadOnly; }
565        }
566
567        /// <summary>
568        /// Searches the list for the first item that compares equal to <paramref name="value"/>.
569        /// If one is found, it is removed. Otherwise, the list is unchanged.
570        /// </summary>
571        /// <remarks>Equality in the list is determined by the default sense of
572        /// equality for T. If T implements IComparable&lt;T&gt;, the
573        /// Equals method of that interface is used to determine equality. Otherwise,
574        /// Object.Equals is used to determine equality.</remarks>
575        /// <param name="value">The item to remove from the list.</param>
576        /// <exception cref="ArgumentException"><paramref name="value"/> cannot be converted to T.</exception>
577        void IList.Remove(object value)
578        {
579            if (value is T || value == null)
580                Remove((T)value);
581        }
582
583        /// <summary>
584        /// Removes the
585        /// item at the given index.
586        /// </summary>
587        /// <param name="index">The index in the list to remove the item at. The
588        /// first item in the list has index 0.</param>
589        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is
590        /// less than zero or greater than or equal to Count.</exception>
591        void IList.RemoveAt(int index)
592        {
593            RemoveAt(index);
594        }
595
596        /// <summary>
597        /// Gets or sets the
598        /// value at a particular index in the list.
599        /// </summary>
600        /// <param name="index">The index in the list to get or set an item at. The
601        /// first item in the list has index 0, and the last has index Count-1.</param>
602        /// <value>The item at the given index.</value>
603        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is
604        /// less than zero or greater than or equal to Count.</exception>
605        /// <exception cref="ArgumentException"><paramref name="value"/> cannot be converted to T.</exception>
606        object IList.this[int index]
607        {
608            get
609            {
610                return this[index];
611            }
612
613            set
614            {
615                this[index] = ConvertToItemType("value", value);
616            }
617        }
618    }
619}
620
Note: See TracBrowser for help on using the repository browser.