@@ -34,6 +34,13 @@ public static string SafeToString(this object obj)
34
34
return str ;
35
35
}
36
36
37
+ /// <summary>
38
+ /// Get the maximum of the elements from the given enumerable.
39
+ /// </summary>
40
+ /// <typeparam name="T">Type of object for which the enumerable is defined.</typeparam>
41
+ /// <param name="elements">An enumerable object of type T</param>
42
+ /// <param name="comparer">A comparer for ordering elements of type T. The comparer should handle null values.</param>
43
+ /// <returns>An object of type T. If the enumerable is empty or has all null elements, then the method returns null.</returns>
37
44
public static T MaxElement < T > ( this IEnumerable < T > elements , Func < T , T , int > comparer ) where T : class
38
45
{
39
46
if ( elements == null )
@@ -63,12 +70,27 @@ public static T MaxElement<T>(this IEnumerable<T> elements, Func<T,T,int> compar
63
70
return maxElement ;
64
71
}
65
72
73
+ /// <summary>
74
+ /// Get the minimum of the elements from the given enumerable.
75
+ /// </summary>
76
+ /// <typeparam name="T">Type of object for which the enumerable is defined.</typeparam>
77
+ /// <param name="elements">An enumerable object of type T</param>
78
+ /// <param name="comparer">A comparer for ordering elements of type T. The comparer should handle null values.</param>
79
+ /// <returns>An object of type T. If the enumerable is empty or has all null elements, then the method returns null.</returns>
66
80
public static T MinElement < T > ( this IEnumerable < T > elements , Func < T , T , int > comparer ) where T : class
67
81
{
68
82
return MaxElement < T > ( elements , ( elementX , elementY ) => - 1 * comparer ( elementX , elementY ) ) ;
69
83
}
70
84
71
- public static int ExtentWitdhComparer ( this IScriptExtent extentX , IScriptExtent extentY )
85
+ /// <summary>
86
+ /// Compare extents with respect to their widths.
87
+ ///
88
+ /// Width of an extent is defined as the difference between its EndOffset and StartOffest properties.
89
+ /// </summary>
90
+ /// <param name="extentX">Extent of type IScriptExtent.</param>
91
+ /// <param name="extentY">Extent of type IScriptExtent.</param>
92
+ /// <returns>0 if extentX and extentY are equal in width. 1 if width of extent X is greater than that of extent Y. Otherwise, -1.</returns>
93
+ public static int ExtentWidthComparer ( this IScriptExtent extentX , IScriptExtent extentY )
72
94
{
73
95
74
96
if ( extentX == null && extentY == null )
@@ -102,6 +124,13 @@ public static int ExtentWitdhComparer(this IScriptExtent extentX, IScriptExtent
102
124
}
103
125
}
104
126
127
+ /// <summary>
128
+ /// Check if the given coordinates are wholly contained in the instance's extent.
129
+ /// </summary>
130
+ /// <param name="scriptExtent">Extent of type IScriptExtent.</param>
131
+ /// <param name="line">1-based line number.</param>
132
+ /// <param name="column">1-based column number</param>
133
+ /// <returns>True if the coordinates are wholly contained in the instance's extent, otherwise, false.</returns>
105
134
public static bool Contains ( this IScriptExtent scriptExtent , int line , int column )
106
135
{
107
136
if ( scriptExtent . StartLineNumber > line || scriptExtent . EndLineNumber < line )
0 commit comments