@@ -59,6 +59,9 @@ public static int IndexOf<T>(this IReadOnlyList<T> s, IReadOnlyList<T> t, IEqual
59
59
/// If <paramref name="t"/> is empty, the return value is 0.
60
60
/// </returns>
61
61
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
62
+ /// <exception cref="ArgumentOutOfRangeException">
63
+ /// <paramref name="startIndex"/> is less than zero or greater than <see cref="IReadOnlyCollection{T}.Count">Count</see> of <paramref name="s"/>.
64
+ /// </exception>
62
65
public static int IndexOf < T > ( this IReadOnlyList < T > s , IReadOnlyList < T > t , int startIndex )
63
66
where T : IEquatable < T >
64
67
{
@@ -80,6 +83,9 @@ public static int IndexOf<T>(this IReadOnlyList<T> s, IReadOnlyList<T> t, int st
80
83
/// If <paramref name="t"/> is empty, the return value is 0.
81
84
/// </returns>
82
85
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
86
+ /// <exception cref="ArgumentOutOfRangeException">
87
+ /// <paramref name="startIndex"/> is less than zero or greater than <see cref="IReadOnlyCollection{T}.Count">Count</see> of <paramref name="s"/>.
88
+ /// </exception>
83
89
public static int IndexOf < T > ( this IReadOnlyList < T > s , IReadOnlyList < T > t , int startIndex , IEqualityComparer < T > comparer )
84
90
where T : IEquatable < T >
85
91
{
@@ -199,7 +205,7 @@ public static int IndexOf(this string s, IReadOnlyList<char> t, int startIndex,
199
205
#region IReadOnlyList(T) (LastIndexOf)
200
206
201
207
/// <summary>
202
- /// Reports the zero-based index of the first occurrence of the specified collection in this instance.
208
+ /// Reports the zero-based index of the last occurrence of the specified collection in this instance.
203
209
/// </summary>
204
210
/// <param name="s">The current collection.</param>
205
211
/// <param name="t">The collection to seek.</param>
@@ -216,7 +222,7 @@ public static int LastIndexOf<T>(this IReadOnlyList<T> s, IReadOnlyList<T> t)
216
222
}
217
223
218
224
/// <summary>
219
- /// Reports the zero-based index of the first occurrence of the specified collection in this instance
225
+ /// Reports the zero-based index of the last occurrence of the specified collection in this instance
220
226
/// and uses the specified <see cref="IEqualityComparer{T}"/>.
221
227
/// </summary>
222
228
/// <param name="s">The current collection.</param>
@@ -235,7 +241,7 @@ public static int LastIndexOf<T>(this IReadOnlyList<T> s, IReadOnlyList<T> t, IE
235
241
}
236
242
237
243
/// <summary>
238
- /// Reports the zero-based index of the first occurrence of the specified collection in this instance.
244
+ /// Reports the zero-based index of the last occurrence of the specified collection in this instance.
239
245
/// The search starts at a specified character position.
240
246
/// </summary>
241
247
/// <param name="s">The current collection.</param>
@@ -247,15 +253,17 @@ public static int LastIndexOf<T>(this IReadOnlyList<T> s, IReadOnlyList<T> t, IE
247
253
/// If <paramref name="t"/> is empty, the return value is the last index position in this instance.
248
254
/// </returns>
249
255
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
250
- /// <exception cref="ArgumentOutOfRangeException"><paramref name="startIndex"/> is less than 0 or greater than the length of this string.</exception>
256
+ /// <exception cref="ArgumentOutOfRangeException">
257
+ /// <paramref name="startIndex"/> is less than zero or greater than <see cref="IReadOnlyCollection{T}.Count">Count</see> of <paramref name="s"/>.
258
+ /// </exception>
251
259
public static int LastIndexOf < T > ( this IReadOnlyList < T > s , IReadOnlyList < T > t , int startIndex )
252
260
where T : IEquatable < T >
253
261
{
254
262
return s . LastIndexOf ( t , startIndex , EqualityComparer < T > . Default ) ;
255
263
}
256
264
257
265
/// <summary>
258
- /// Reports the zero-based index of the first occurrence of the specified collection in this instance
266
+ /// Reports the zero-based index of the last occurrence of the specified collection in this instance
259
267
/// and uses the specified <see cref="IEqualityComparer{T}"/>.
260
268
/// The search starts at a specified character position.
261
269
/// </summary>
@@ -269,7 +277,9 @@ public static int LastIndexOf<T>(this IReadOnlyList<T> s, IReadOnlyList<T> t, in
269
277
/// If <paramref name="t"/> is empty, the return value is the last index position in this instance.
270
278
/// </returns>
271
279
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
272
- /// <exception cref="ArgumentOutOfRangeException"><paramref name="startIndex"/> is less than 0 or greater than the length of this string.</exception>
280
+ /// <exception cref="ArgumentOutOfRangeException">
281
+ /// <paramref name="startIndex"/> is less than zero or greater than <see cref="IReadOnlyCollection{T}.Count">Count</see> of <paramref name="s"/>.
282
+ /// </exception>
273
283
public static int LastIndexOf < T > ( this IReadOnlyList < T > s , IReadOnlyList < T > t , int startIndex , IEqualityComparer < T > comparer )
274
284
where T : IEquatable < T >
275
285
{
@@ -315,7 +325,7 @@ public static int LastIndexOf<T>(this IReadOnlyList<T> s, IReadOnlyList<T> t, in
315
325
#region String (LastIndexOf)
316
326
317
327
/// <summary>
318
- /// Reports the zero-based index of the first occurrence of the specified character collection in this instance.
328
+ /// Reports the zero-based index of the last occurrence of the specified character collection in this instance.
319
329
/// </summary>
320
330
/// <param name="s">The string instance.</param>
321
331
/// <param name="t">The character collection to seek.</param>
@@ -330,7 +340,7 @@ public static int LastIndexOf(this string s, IReadOnlyList<char> t)
330
340
}
331
341
332
342
/// <summary>
333
- /// Reports the zero-based index of the first occurrence of the specified character collection in this instance
343
+ /// Reports the zero-based index of the last occurrence of the specified character collection in this instance
334
344
/// and uses the specified <see cref="IEqualityComparer{Char}"/>.
335
345
/// </summary>
336
346
/// <param name="s">The string instance.</param>
@@ -347,7 +357,7 @@ public static int LastIndexOf(this string s, IReadOnlyList<char> t, EqualityComp
347
357
}
348
358
349
359
/// <summary>
350
- /// Reports the zero-based index of the first occurrence of the specified character collection in this instance.
360
+ /// Reports the zero-based index of the last occurrence of the specified character collection in this instance.
351
361
/// The search starts at a specified character position.
352
362
/// </summary>
353
363
/// <param name="s">The string instance.</param>
@@ -363,9 +373,9 @@ public static int LastIndexOf(this string s, IReadOnlyList<char> t, int startInd
363
373
{
364
374
return s . AsReadOnlyList ( ) . LastIndexOf ( t , startIndex , EqualityComparer < char > . Default ) ;
365
375
}
366
-
376
+
367
377
/// <summary>
368
- /// Reports the zero-based index of the first occurrence of the specified character collection in this instance
378
+ /// Reports the zero-based index of the last occurrence of the specified character collection in this instance
369
379
/// and uses the specified <see cref="IEqualityComparer{Char}"/>.
370
380
/// The search starts at a specified character position.
371
381
/// </summary>
@@ -387,25 +397,83 @@ public static int LastIndexOf(this string s, IReadOnlyList<char> t, int startInd
387
397
#endregion
388
398
389
399
#region IReadOnlyList(T) (IndexesOf)
390
-
400
+
401
+ /// <summary>
402
+ /// Enumerates each zero-based index of all occurrences of the specified collection in this instance.
403
+ /// </summary>
404
+ /// <param name="s">The current collection.</param>
405
+ /// <param name="t">The collection to seek.</param>
406
+ /// <typeparam name="T">The type of element in the collection.</typeparam>
407
+ /// <returns>
408
+ /// The zero-based index positions of value if one or more <paramref name="t"/> is found.
409
+ /// If <paramref name="t"/> is empty, no indexes will be enumerated.
410
+ /// </returns>
411
+ /// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
391
412
public static IEnumerable < int > IndexesOf < T > ( this IReadOnlyList < T > s , IReadOnlyList < T > t )
392
413
where T : IEquatable < T >
393
414
{
394
415
return s . IndexesOf ( t , 0 , EqualityComparer < T > . Default ) ;
395
416
}
396
417
418
+ /// <summary>
419
+ /// Enumerates each zero-based index of all occurrences of the specified collection in this instance
420
+ /// and uses the specified <see cref="IEqualityComparer{T}"/>.
421
+ /// </summary>
422
+ /// <param name="s">The current collection.</param>
423
+ /// <param name="t">The collection to seek.</param>
424
+ /// <param name="comparer">The specified <see cref="IEqualityComparer{T}"/> instance.</param>
425
+ /// <typeparam name="T">The type of element in the collection.</typeparam>
426
+ /// <returns>
427
+ /// The zero-based index positions of value if one or more <paramref name="t"/> is found.
428
+ /// If <paramref name="t"/> is empty, no indexes will be enumerated.
429
+ /// </returns>
430
+ /// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
397
431
public static IEnumerable < int > IndexesOf < T > ( this IReadOnlyList < T > s , IReadOnlyList < T > t , IEqualityComparer < T > comparer )
398
432
where T : IEquatable < T >
399
433
{
400
434
return s . IndexesOf ( t , 0 , comparer ) ;
401
435
}
402
436
437
+ /// <summary>
438
+ /// Enumerates each zero-based index of all occurrences of the specified collection in this instance.
439
+ /// The search starts at a specified position.
440
+ /// </summary>
441
+ /// <param name="s">The current collection.</param>
442
+ /// <param name="t">The collection to seek.</param>
443
+ /// <param name="startIndex">The search starting position.</param>
444
+ /// <typeparam name="T">The type of element in the collection.</typeparam>
445
+ /// <returns>
446
+ /// The zero-based index positions of value if one or more <paramref name="t"/> is found.
447
+ /// If <paramref name="t"/> is empty, no indexes will be enumerated.
448
+ /// </returns>
449
+ /// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
450
+ /// <exception cref="ArgumentOutOfRangeException">
451
+ /// <paramref name="startIndex"/> is less than zero or greater than <see cref="IReadOnlyCollection{T}.Count">Count</see> of <paramref name="s"/>.
452
+ /// </exception>
403
453
public static IEnumerable < int > IndexesOf < T > ( this IReadOnlyList < T > s , IReadOnlyList < T > t , int startIndex )
404
454
where T : IEquatable < T >
405
455
{
406
456
return s . IndexesOf ( t , startIndex , EqualityComparer < T > . Default ) ;
407
457
}
408
458
459
+ /// <summary>
460
+ /// Enumerates each zero-based index of all occurrences of the specified collection in this instance
461
+ /// and uses the specified <see cref="IEqualityComparer{T}"/>.
462
+ /// The search starts at a specified position.
463
+ /// </summary>
464
+ /// <param name="s">The current collection.</param>
465
+ /// <param name="t">The collection to seek.</param>
466
+ /// <param name="startIndex">The search starting position.</param>
467
+ /// <param name="comparer">The specified <see cref="IEqualityComparer{T}"/> instance.</param>
468
+ /// <typeparam name="T">The type of element in the collection.</typeparam>
469
+ /// <returns>
470
+ /// The zero-based index positions of value if one or more <paramref name="t"/> is found.
471
+ /// If <paramref name="t"/> is empty, no indexes will be enumerated.
472
+ /// </returns>
473
+ /// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
474
+ /// <exception cref="ArgumentOutOfRangeException">
475
+ /// <paramref name="startIndex"/> is less than zero or greater than <see cref="IReadOnlyCollection{T}.Count">Count</see> of <paramref name="s"/>.
476
+ /// </exception>
409
477
public static IEnumerable < int > IndexesOf < T > ( this IReadOnlyList < T > s , IReadOnlyList < T > t , int startIndex , IEqualityComparer < T > comparer )
410
478
where T : IEquatable < T >
411
479
{
@@ -579,7 +647,7 @@ public static IEnumerable<int> LastIndexesOf(this string s, IReadOnlyList<char>
579
647
#endregion
580
648
581
649
#region Wrapper
582
-
650
+
583
651
public static IReadOnlyList < T > AsReadOnlyList < T > ( this IList < T > list )
584
652
where T : IEquatable < T >
585
653
{
0 commit comments