懒得勤快 10 달 전
부모
커밋
caf34d396d
1개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 5 4
      Masuit.Tools.Abstractions/Extensions/BaseType/IEnumerableExtensions.cs

+ 5 - 4
Masuit.Tools.Abstractions/Extensions/BaseType/IEnumerableExtensions.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Collections;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Diagnostics;
@@ -638,9 +639,9 @@ public static class IEnumerableExtensions
     /// <typeparam name="T"></typeparam>
     /// <param name="source"></param>
     /// <returns></returns>
-    public static SortedSet<T> ToSortedSet<T>(this IEnumerable<T> source)
+    public static SortedSet<T> ToSortedSet<T>(this IEnumerable<T> source, IComparer<T> comparer = null)
     {
-        return [.. source];
+        return comparer == null ? [.. source] : new SortedSet<T>(source, comparer);
     }
 
     /// <summary>
@@ -651,9 +652,9 @@ public static class IEnumerableExtensions
     /// <param name="source"></param>
     /// <param name="selector"></param>
     /// <returns></returns>
-    public static SortedSet<TResult> ToSortedSet<T, TResult>(this IEnumerable<T> source, Func<T, TResult> selector)
+    public static SortedSet<TResult> ToSortedSet<T, TResult>(this IEnumerable<T> source, Func<T, TResult> selector, IComparer<TResult> comparer = null)
     {
-        return [.. source.Select(selector)];
+        return comparer == null ? [.. source.Select(selector)] : new SortedSet<TResult>(source.Select(selector), comparer);
     }
 
     /// <summary>