集合操作
19 個節點
本頁內容 19
新增
函數此節點沒有文件說明。
新增(集合: T 集合, 項: T) -> 真否
bool Add(HashSet<T> set, T item)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | |
| 項 | T | — |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
清空
函數Removes every element from the set, in place; the set itself stays usable and keeps its equality rule.
清空(集合: T 集合)
void Clear(HashSet<T> set)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set to empty. |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
複製集合
函數An independent copy of the set with the same elements and the same equality rule, so that changing one does not change the other. The elements themselves are shared, not copied.
複製集合(集合: T 集合) -> T 集合
HashSet<T> Clone(HashSet<T> set)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set to copy. |
返回
| 結果 | T 集合 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
比較器
函數The equality rule the set uses to decide which elements are the same, for creating another set that behaves alike.
比較器(集合: T 集合) -> IEqualityComparer<T>
IEqualityComparer<T> Comparer(HashSet<T> set)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set to inspect. |
返回
| 結果 | IEqualityComparer<T> |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
包含
函數Whether the set holds an element equal to Item, by the set's own equality rule; this is a fast lookup, however large the set.
包含(集合: T 集合, 項: T) -> 真否
bool Contains(HashSet<T> set, T item)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set to search. |
| 項 | T | — | The element to look for. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
項數
函數How many elements the set holds.
項數(集合: T 集合) -> 整數
int Count(HashSet<T> set)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set to measure. |
返回
| 結果 | 整數 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
建立集合
函數過載 1/5
建立集合() -> T 集合
HashSet<T> Create()
A new, empty set that compares its elements by their default equality.
返回
| 結果 | T 集合 |
過載 2/5
建立集合(容量: 整數) -> T 集合
HashSet<T> Create(int capacity)
A new, empty set with room for Capacity elements before it has to grow, for when the final size is known in advance. Throws System.ArgumentOutOfRangeException when Capacity is negative.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 容量 | 整數 | — | How many elements to make room for. |
返回
| 結果 | T 集合 |
過載 3/5
建立集合(比較器: IEqualityComparer<T>) -> T 集合
HashSet<T> Create(IEqualityComparer<T> comparer)
A new, empty set that uses Comparer to decide which elements are the same, for example text compared without regard to case.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 比較器 | IEqualityComparer<T> | — | Decides whether two elements are equal; null uses the default equality. |
返回
| 結果 | T 集合 |
過載 4/5
建立集合(源: IEnumerable<T>) -> T 集合
HashSet<T> Create(IEnumerable<T> source)
A new set holding the elements of a sequence, with duplicates dropped, compared by their default equality.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 源 | IEnumerable<T> | — | The elements to put in the set. |
返回
| 結果 | T 集合 |
過載 5/5
建立集合 -> T 集合
源: IEnumerable<T>
比較器: IEqualityComparer<T>HashSet<T> Create(
IEnumerable<T> source,
IEqualityComparer<T> comparer)A new set holding the elements of a sequence, with Comparer deciding which ones are duplicates; the set keeps using it afterwards.
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 源 | IEnumerable<T> | — | The elements to put in the set. |
| 比較器 | IEqualityComparer<T> | — | Decides whether two elements are equal; null uses the default equality. |
返回
| 結果 | T 集合 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
差集
函數The first operand's elements minus the second's, in a new set; both operands untouched.
差集(集合: T 集合, 另一個: IEnumerable<T>) -> T 集合
HashSet<T> Except(HashSet<T> set, IEnumerable<T> other)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | |
| 另一個 | IEnumerable<T> | — |
返回
| 結果 | T 集合 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
交集
函數Only the elements both operands have, in a new set; both operands untouched.
交集(集合: T 集合, 另一個: IEnumerable<T>) -> T 集合
HashSet<T> Intersect(HashSet<T> set, IEnumerable<T> other)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | |
| 另一個 | IEnumerable<T> | — |
返回
| 結果 | T 集合 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
為空
函數Whether the set holds no elements.
為空(集合: T 集合) -> 真否
bool IsEmpty(HashSet<T> set)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set to test. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
是否為子集
函數Whether every element of Set is also in Other, by the set's equality rule. An empty set is a subset of anything, and a set is a subset of itself.
是否為子集(集合: T 集合, 另一個: IEnumerable<T>) -> 真否
bool IsSubsetOf(HashSet<T> set, IEnumerable<T> other)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set that should be contained. |
| 另一個 | IEnumerable<T> | — | The elements it should be contained in; duplicates and order do not matter. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
是否為超集
函數Whether every element of Other is also in Set, by the set's equality rule. Any set is a superset of an empty sequence.
是否為超集(集合: T 集合, 另一個: IEnumerable<T>) -> 真否
bool IsSupersetOf(HashSet<T> set, IEnumerable<T> other)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set that should contain the elements. |
| 另一個 | IEnumerable<T> | — | The elements it should contain; duplicates and order do not matter. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
是否有交集
函數Whether the set and the other elements have at least one element in common, by the set's equality rule; false when either is empty.
是否有交集(集合: T 集合, 另一個: IEnumerable<T>) -> 真否
bool Overlaps(HashSet<T> set, IEnumerable<T> other)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set to test. |
| 另一個 | IEnumerable<T> | — | The elements to look for in the set. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
移除
函數此節點沒有文件說明。
移除(集合: T 集合, 項: T) -> 真否
bool Remove(HashSet<T> set, T item)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | |
| 項 | T | — |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
集合相等
函數Whether the set and the other elements hold exactly the same elements, by the set's equality rule, ignoring order and any duplicates in Other.
集合相等(集合: T 集合, 另一個: IEnumerable<T>) -> 真否
bool SetEquals(HashSet<T> set, IEnumerable<T> other)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set to compare. |
| 另一個 | IEnumerable<T> | — | The elements to compare it with. |
返回
| 結果 | 真否 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
對稱差集
函數The elements in exactly one of the two operands, in a new set; both operands untouched.
對稱差集(集合: T 集合, 另一個: IEnumerable<T>) -> T 集合
HashSet<T> SymmetricExcept(HashSet<T> set, IEnumerable<T> other)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | |
| 另一個 | IEnumerable<T> | — |
返回
| 結果 | T 集合 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
轉為陣列
函數Copies the set's elements into a new array, for when an indexed or ordered collection is needed. The order is whatever order the set happens to hold them in, which is not guaranteed to be insertion order.
轉為陣列(集合: T 集合) -> T 陣列
T[] ToArray(HashSet<T> set)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set to copy. |
返回
| 結果 | T 陣列 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
轉為列表
函數Copies the set's elements into a new list, for when an indexed collection that can hold duplicates is needed. The order is whatever order the set happens to hold them in, which is not guaranteed to be insertion order.
轉為列表(集合: T 集合) -> T 列表
List<T> ToList(HashSet<T> set)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | The set to copy. |
返回
| 結果 | T 列表 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫
並集
函數Every element in either operand, in a new set; both operands untouched.
並集(集合: T 集合, 另一個: IEnumerable<T>) -> T 集合
HashSet<T> Union(HashSet<T> set, IEnumerable<T> other)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 集合 | T 集合 | — | |
| 另一個 | IEnumerable<T> | — |
返回
| 結果 | T 集合 |
- 所屬發行版
- 元編程(教育版)元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 集合操作
- 所屬包
- 標準庫