Today I Learned :
Linq: Distinct, Union, Intersect, Except
- Distinct : 중복 제거
- Union : 합집합, 중복요소는 제거
- Intersect : 교집합
- Except : 차집합. a-b
List<int> numbers = new List<int> { 1, 2, 2, 3, 3, 4, 5, 5 };
var distinctNumbers = numbers.Distinct();
// 결과: { 1, 2, 3, 4, 5 }
List<int> list1 = new List<int> { 1, 2, 3 };
List<int> list2 = new List<int> { 3, 4, 5 };
var union = list1.Union(list2);
// 결과: { 1, 2, 3, 4, 5 }
List<int> list1 = new List<int> { 1, 2, 3, 4, 5 };
List<int> list2 = new List<int> { 3, 4, 5, 6, 7 };
var intersect = list1.Intersect(list2);
// 결과: { 3, 4, 5 }
List<int> list1 = new List<int> { 1, 2, 3, 4, 5 };
List<int> list2 = new List<int> { 3, 4, 5 };
var except = list1.Except(list2);
// 결과: { 1, 2 }
FSM
유한 상태 기계(Finite State Machine, FSM)
정해진 상태(State)가 있고 이 상태는 동시에 하나만 갖고 있을 수 있다.
입력에 따라(Event) 상태가 바뀌는 전이(Transition)과정이 있다.
유니티 외부 라이브러리
https://github.com/thefuntastic/Unity3d-Finite-State-Machine
장점
- 이벤트 기반 시스템을 모델링할 때 유용
- 확장성이 용이하고 가독성과 유지보수성이 좋다
단점
- 상태가 많아지고 상태간의 전이가 복잡해지면 관리가 어렵다
- 상태간의 관계가 복잡해지면 모든 경우의 수를 다루기 힘들다.
'TIL' 카테고리의 다른 글
20240221 TIL (0) | 2024.02.21 |
---|---|
20240220 TIL (1) | 2024.02.20 |
20240215 TIL (0) | 2024.02.15 |
20240214 TIL (1) | 2024.02.15 |
20240213 TIL (0) | 2024.02.13 |