43 lines
2.0 KiB
C#
43 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace ServerCore;
|
|
|
|
/// <summary>
|
|
/// 두 컬렉션의 키(Key)를 비교하는 기능을 제공하는 정적 유틸리티 클래스입니다.
|
|
/// </summary>
|
|
public static class KeyComparer
|
|
{
|
|
/// <summary>
|
|
/// 두 개의 딕셔너리를 비교하여, 두 번째 딕셔너리(second)에만 존재하는 키(Key)들의 리스트를 반환합니다.
|
|
/// 첫 번째 딕셔너리(first)에는 없고 두 번째 딕셔너리에 새로 추가된 키를 찾을 때 유용합니다.
|
|
/// </summary>
|
|
/// <typeparam name="TKey">딕셔너리의 키 타입</typeparam>
|
|
/// <typeparam name="TValue">딕셔너리의 값 타입</typeparam>
|
|
/// <param name="first">비교의 기준이 되는 첫 번째 딕셔너리</param>
|
|
/// <param name="second">새로운 키를 찾을 대상이 되는 두 번째 딕셔너리</param>
|
|
/// <returns>두 번째 딕셔너리에만 존재하는 키의 리스트</returns>
|
|
public static List<TKey> getKeysOnlyInSecond<TKey, TValue>(Dictionary<TKey, TValue> first, Dictionary<TKey, TValue> second)
|
|
where TKey : notnull
|
|
where TValue : notnull
|
|
{
|
|
return second.Keys.Except(first.Keys).ToList();
|
|
}
|
|
/// <summary>
|
|
/// 두 개의 리스트를 비교하여, 두 번째 리스트(second)에만 존재하는 요소들의 리스트를 반환합니다.
|
|
/// </summary>
|
|
/// <typeparam name="TKey">리스트 요소의 타입</typeparam>
|
|
/// <param name="first">비교의 기준이 되는 첫 번째 리스트</param>
|
|
/// <param name="second">새로운 요소를 찾을 대상이 되는 두 번째 리스트</param>
|
|
/// <returns>두 번째 리스트에만 존재하는 요소의 리스트</returns>
|
|
public static List<TKey> getKeysOnlyInSecond<TKey>(List<TKey> first, List<TKey> second)
|
|
where TKey : notnull
|
|
{
|
|
return second.Except(first).ToList();
|
|
}
|
|
}
|