set

package
v0.0.0-...-7a9c835 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

hash set

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T constraints.Ordered] map[T]struct{}

func New

func New[T constraints.Ordered]() Set[T]

Set is a container that stores unique values.

func (Set[T]) Clear

func (s Set[T]) Clear() Set[T]

func (Set[T]) Clone

func (s Set[T]) Clone() Set[T]

DeepClone returns a deep copy of the set.

func (Set[T]) Contain

func (s Set[T]) Contain(val T) bool

If value is not in the set, return true. If value is in the set, return false.

func (Set[T]) ContainAndRemove

func (s Set[T]) ContainAndRemove(val T) (ok bool)

If value is in the set, return true and remove it.

func (Set[T]) CopyFrom

func (s Set[T]) CopyFrom(set Set[T]) Set[T]

func (Set[T]) Difference

func (s Set[T]) Difference(set Set[T]) (diff Set[T])

Contains all elements in the original s but not in the set

func (Set[T]) Equal

func (s Set[T]) Equal(set Set[T]) (b bool)

func (Set[T]) Insert

func (s Set[T]) Insert(val T) bool

Slice returns a slice of the set. If value is not in the set, return true. If value is in the set, return false.

func (Set[T]) Intersection

func (s Set[T]) Intersection(set Set[T]) (intersection Set[T])

Contains all elements in s and set.

func (Set[T]) IsEmpty

func (s Set[T]) IsEmpty() bool

func (Set[T]) IsSubSet

func (s Set[T]) IsSubSet(set Set[T]) (b bool)

If s is a subset of set, return true.

func (Set[T]) IsSupperSet

func (s Set[T]) IsSupperSet(set Set[T]) (b bool)

If s is a supper set of set, return true.

func (Set[T]) Len

func (s Set[T]) Len() int

Len returns the length of the set.

func (Set[T]) Push

func (s Set[T]) Push(val ...T) Set[T]

func (Set[T]) Range

func (s Set[T]) Range(f func(val T) (Continue bool))

func (Set[T]) Remove

func (s Set[T]) Remove(val T) bool

Remove removes the value from the set. If value is in the set, return true. If value is not in the set, return false.

func (Set[T]) Slice

func (s Set[T]) Slice() []T

func (Set[T]) SymmetricDifference

func (s Set[T]) SymmetricDifference(set Set[T]) (diff Set[T])

Contains all elements in s or set but not both.

func (Set[T]) Union

func (s Set[T]) Union(set ...Set[T]) (union Set[T])

Union all sets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL