Documentation
¶
Index ¶
- type Set
- func (s Set[T]) Add(item T)
- func (s Set[T]) AddAll(items []T)
- func (s Set[T]) All() iter.Seq[T]
- func (s Set[T]) Clear()
- func (s Set[T]) Clone() Set[T]
- func (s Set[T]) Contains(item T) bool
- func (s Set[T]) ContainsAll(items []T) bool
- func (s Set[T]) ContainsAny(items []T) bool
- func (s Set[T]) Difference(other Set[T]) Set[T]
- func (s Set[T]) Equal(other Set[T]) bool
- func (s Set[T]) Intersection(other Set[T]) Set[T]
- func (s Set[T]) IsDisjoint(other Set[T]) bool
- func (s Set[T]) IsEmpty() bool
- func (s Set[T]) IsSubsetOf(other Set[T]) bool
- func (s Set[T]) IsSupersetOf(other Set[T]) bool
- func (s Set[T]) Remove(item T)
- func (s Set[T]) RemoveAll(items []T)
- func (s Set[T]) Size() int
- func (s Set[T]) SymmetricDifference(other Set[T]) Set[T]
- func (s Set[T]) ToSlice() []T
- func (s Set[T]) Union(other Set[T]) Set[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T comparable] map[T]struct{}
Set は Go の map 型を使用したハッシュ集合データ構造を表します。 ゼロ値は使用可能ではありません。新しい Set を作成するには New() を使用してください。
func NewFromSlice ¶
func NewFromSlice[T comparable](items []T) Set[T]
NewFromSlice は指定されたスライスから一意の要素をすべて含む新しい Set を作成して返します。
func NewWithCapacity ¶
func NewWithCapacity[T comparable](capacity int) Set[T]
NewWithCapacity は指定された初期容量で新しい空の Set を作成して返します。 概算サイズが分かっている場合、メモリ割り当てを削減するのに役立ちます。
func (Set[T]) All ¶
All は集合のすべての要素を反復処理するための iter.Seq[T] を返します。 これにより、for range ループで Set を直接反復処理できます。 例: for item := range mySet.All() { ... }
func (Set[T]) ContainsAll ¶
ContainsAll は指定されたスライスのすべての要素が集合に存在するかどうかを報告します。 すべての要素が存在する場合は true、そうでなければ false を返します。
func (Set[T]) ContainsAny ¶
ContainsAny は指定されたスライスのいずれかの要素が集合に存在するかどうかを報告します。 少なくとも一つの要素が存在する場合は true、そうでなければ false を返します。
func (Set[T]) Difference ¶
Difference は差集合を返します。 元の集合は変更されません。
func (Set[T]) Intersection ¶
Intersection は積集合を返します。 元の集合は変更されません。
func (Set[T]) IsDisjoint ¶
IsDisjoint はこの集合と他の集合が共通要素を持たないかどうかを報告します。
func (Set[T]) IsSubsetOf ¶
IsSubsetOf はこの集合が他の集合の部分集合かどうかを報告します。 この集合のすべての要素が他の集合にも存在する場合は true を返します。
func (Set[T]) IsSupersetOf ¶
IsSupersetOf はこの集合が他の集合の上位集合かどうかを報告します。 他の集合のすべての要素がこの集合にも存在する場合は true を返します。
func (Set[T]) RemoveAll ¶
func (s Set[T]) RemoveAll(items []T)
RemoveAll は指定されたスライスのすべての要素を集合から削除します。
func (Set[T]) SymmetricDifference ¶
SymmetricDifference は対称差集合を返します。 元の集合は変更されません。