base/collection/set
셋 (중복 불허 집합).
Set (a collection without duplicates).
Setextends Object
셋 (중복 불허 집합).
Set (a collection without duplicates).
import { Set } from "./build/vanilla.js";
const left = new Set();
left.add(1);
left.add(2);
left.add(2);
const right = new Set();
right.add(2);
right.add(3);
console.log(left.getCount(), left.union(right).toArray(), left.intersection(right).toArray(), left.difference(right).toArray());생성.
Constructor.
데이터 추가.
Adds data.
- itemT
- 더할 요소. (이미 있으면 그대로)Item to add. (unchanged if already present)
데이터 제거.
Removes data.
- itemT
- 지울 요소.Item to remove.
반환Returnsboolean 있어서 지웠으면 참.True if it existed and was removed.
요소 포함 여부 반환.
Returns whether the element is contained.
- itemT
- 찾을 요소.Item to look for.
반환Returnsboolean 있으면 참.True if present.
합집합. (Union)
Union. (Union)
- otherSetSet<T>
- 합칠 다른 셋.Other set to combine.
반환ReturnsSet<T> 두 셋의 요소를 모두 담은 새 셋.New set with all items of both sets.
교집합. (Intersection)
Intersection. (Intersection)
- otherSetSet<T>
- 견줄 다른 셋.Other set to compare.
반환ReturnsSet<T> 두 셋에 모두 있는 요소만 담은 새 셋.New set with only the items present in both sets.
차집합. (Difference)
Difference. (Difference)
- otherSetSet<T>
- 뺄 다른 셋.Other set to subtract.
반환ReturnsSet<T> 이 셋에만 있고 다른 셋에는 없는 요소를 담은 새 셋.New set with the items in this set that are not in the other set.
대칭 차집합 (여집합). (Symmetric Difference)
Symmetric difference (complement). (Symmetric Difference)
- otherSetSet<T>
- 견줄 다른 셋.Other set to compare.
반환ReturnsSet<T> 두 셋 가운데 한쪽에만 있는 요소를 담은 새 셋.New set with the items present in only one of the two sets.
전체 제거.
Removes all.
전체 요소 배열 반환.
Returns an array of all elements.
반환ReturnsT[] 넣은 차례의 요소를 담은 새 배열.New array of items in insertion order.