유니티 C# 해시셋 HashSet 사용법 예시 간단 구현


유니티 C# 해시셋 HashSet 사용법 예시 간단 구현

HashSet 고유한 요소 집합을 저장하는 컬렉션입니다. 즉, 중복 값을 허용하지 않습니다. 생성 HashSet numbers = new HashSet(); 요소 추가 numbers.Add(1); numbers.Add(2); numbers.Add(3); numbers.Add(1); // 1은 추가되지 않음. (중복됨) 요소 제거 numbers.Remove(2); 개수 확인 int count = numbers.Count; 루프 사용 foreach (int number in numbers) { } 해쉬 삭제 numbers.Clear(); 합집합, 교집합, 차집합 HashSet otherSet = new HashSet { 2, 3, 4 }; numbers.UnionWith(otherSet); // 다른 집합의..


원문링크 : 유니티 C# 해시셋 HashSet 사용법 예시 간단 구현