Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 003c40c

Browse files
committed
Add documentary comments
1 parent fee828b commit 003c40c

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

‎src/AlgorithmForce.Searching/Extensions.cs‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace AlgorithmForce.Searching
55
{
6+
/// <summary>
7+
/// Provides a set of extensions for searching specified collection in another collection.
8+
/// </summary>
69
public static class Extensions
710
{
811
#region IReadOnlyList(T) (IndexOf)
@@ -69,21 +72,71 @@ public static int IndexOf<T>(this IReadOnlyList<T> s, IReadOnlyList<T> t, int st
6972

7073
#region String (IndexOf)
7174

75+
/// <summary>
76+
/// Reports the zero-based index of the first occurrence of the specified character collection in this instance.
77+
/// </summary>
78+
/// <param name="s">The string instance.</param>
79+
/// <param name="t">The character collection to seek.</param>
80+
/// <returns>
81+
/// The zero-based index position of value if that string is found, or -1 if it is not.
82+
/// If <see cref="t"/> is empty, the return value is 0.
83+
/// </returns>
84+
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
7285
public static int IndexOf(this string s, IReadOnlyList<char> t)
7386
{
7487
return s.AsReadOnlyList().IndexOf(t, 0, EqualityComparer<char>.Default);
7588
}
7689

90+
/// <summary>
91+
/// Reports the zero-based index of the first occurrence of the specified character collection in this instance
92+
/// and uses the specified <see cref="IEqualityComparer{Char}"/>.
93+
/// </summary>
94+
/// <param name="s">The string instance.</param>
95+
/// <param name="t">The character collection to seek.</param>
96+
/// <param name="comparer">The specified <see cref="IEqualityComparer{Char}"/> instance.</param>
97+
/// <returns>
98+
/// The zero-based index position of value if that string is found, or -1 if it is not.
99+
/// If <see cref="t"/> is empty, the return value is 0.
100+
/// </returns>
101+
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
77102
public static int IndexOf(this string s, IReadOnlyList<char> t, EqualityComparer<char> comparer)
78103
{
79104
return s.AsReadOnlyList().IndexOf(t, 0, comparer);
80105
}
81106

107+
/// <summary>
108+
/// Reports the zero-based index of the first occurrence of the specified character collection in this instance.
109+
/// The search starts at a specified character position.
110+
/// </summary>
111+
/// <param name="s">The string instance.</param>
112+
/// <param name="t">The character collection to seek.</param>
113+
/// <param name="startIndex">The search starting position.</param>
114+
/// <returns>
115+
/// The zero-based index position of value if that string is found, or -1 if it is not.
116+
/// If <see cref="t"/> is empty, the return value is 0.
117+
/// </returns>
118+
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
119+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="startIndex"/> is less than 0 or greater than the length of this string.</exception>
82120
public static int IndexOf(this string s, IReadOnlyList<char> t, int startIndex)
83121
{
84122
return s.AsReadOnlyList().IndexOf(t, startIndex, EqualityComparer<char>.Default);
85123
}
86124

125+
/// <summary>
126+
/// Reports the zero-based index of the first occurrence of the specified character collection in this instance
127+
/// and uses the specified <see cref="IEqualityComparer{Char}"/>.
128+
/// The search starts at a specified character position.
129+
/// </summary>
130+
/// <param name="s">The string instance.</param>
131+
/// <param name="t">The character collection to seek.</param>
132+
/// <param name="startIndex">The search starting position.</param>
133+
/// <param name="comparer">The specified <see cref="IEqualityComparer{Char}"/> instance.</param>
134+
/// <returns>
135+
/// The zero-based index position of value if that string is found, or -1 if it is not.
136+
/// If <see cref="t"/> is empty, the return value is 0.
137+
/// </returns>
138+
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
139+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="startIndex"/> is less than 0 or greater than the length of this string.</exception>
87140
public static int IndexOf(this string s, IReadOnlyList<char> t, int startIndex, EqualityComparer<char> comparer)
88141
{
89142
return s.AsReadOnlyList().IndexOf(t, startIndex, comparer);
@@ -155,21 +208,72 @@ public static int LastIndexOf<T>(this IReadOnlyList<T> s, IReadOnlyList<T> t, in
155208

156209
#region String (LastIndexOf)
157210

211+
/// <summary>
212+
/// Reports the zero-based index of the first occurrence of the specified character collection in this instance.
213+
/// </summary>
214+
/// <param name="s">The string instance.</param>
215+
/// <param name="t">The character collection to seek.</param>
216+
/// <returns>
217+
/// The zero-based index position of value if that string is found, or -1 if it is not.
218+
/// If <see cref="t"/> is empty, the return value is the last index position in this instance.
219+
/// </returns>
220+
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
158221
public static int LastIndexOf(this string s, IReadOnlyList<char> t)
159222
{
160223
return s.AsReadOnlyList().LastIndexOf(t, s == null ? -1 : s.Length - 1, EqualityComparer<char>.Default);
161224
}
162225

226+
/// <summary>
227+
/// Reports the zero-based index of the first occurrence of the specified character collection in this instance
228+
/// and uses the specified <see cref="IEqualityComparer{Char}"/>.
229+
/// </summary>
230+
/// <param name="s">The string instance.</param>
231+
/// <param name="t">The character collection to seek.</param>
232+
/// <param name="comparer">The specified <see cref="IEqualityComparer{Char}"/> instance.</param>
233+
/// <returns>
234+
/// The zero-based index position of value if that string is found, or -1 if it is not.
235+
/// If <see cref="t"/> is empty, the return value is the last index position in this instance.
236+
/// </returns>
237+
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
163238
public static int LastIndexOf(this string s, IReadOnlyList<char> t, EqualityComparer<char> comparer)
164239
{
165240
return s.AsReadOnlyList().LastIndexOf(t, s == null ? -1 : s.Length - 1, comparer);
166241
}
167242

243+
/// <summary>
244+
/// Reports the zero-based index of the first occurrence of the specified character collection in this instance.
245+
/// The search starts at a specified character position.
246+
/// </summary>
247+
/// <param name="s">The string instance.</param>
248+
/// <param name="t">The character collection to seek.</param>
249+
/// <param name="startIndex">The search starting position.</param>
250+
/// <returns>
251+
/// The zero-based index position of value if that string is found, or -1 if it is not.
252+
/// If <see cref="t"/> is empty, the return value is the last index position in this instance.
253+
/// </returns>
254+
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
255+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="startIndex"/> is less than 0 or greater than the length of this string.</exception>
168256
public static int LastIndexOf(this string s, IReadOnlyList<char> t, int startIndex)
169257
{
170258
return s.AsReadOnlyList().LastIndexOf(t, startIndex, EqualityComparer<char>.Default);
171259
}
172260

261+
262+
/// <summary>
263+
/// Reports the zero-based index of the first occurrence of the specified character collection in this instance
264+
/// and uses the specified <see cref="IEqualityComparer{Char}"/>.
265+
/// The search starts at a specified character position.
266+
/// </summary>
267+
/// <param name="s">The string instance.</param>
268+
/// <param name="t">The character collection to seek.</param>
269+
/// <param name="startIndex">The search starting position.</param>
270+
/// <param name="comparer">The specified <see cref="IEqualityComparer{Char}"/> instance.</param>
271+
/// <returns>
272+
/// The zero-based index position of value if that string is found, or -1 if it is not.
273+
/// If <see cref="t"/> is empty, the return value is the last index position in this instance.
274+
/// </returns>
275+
/// <exception cref="ArgumentNullException"><paramref name="s"/> or <paramref name="t"/> is null.</exception>
276+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="startIndex"/> is less than 0 or greater than the length of this string.</exception>
173277
public static int LastIndexOf(this string s, IReadOnlyList<char> t, int startIndex, EqualityComparer<char> comparer)
174278
{
175279
return s.AsReadOnlyList().LastIndexOf(t, startIndex, comparer);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /