datastructure

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 0 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T comparable] map[T]bool

Set is a data container, like slice, but element of set is not duplicate

func NewSet

func NewSet[T comparable](values ...T) Set[T]

NewSet return a instance of set

func (Set[T]) Add

func (s Set[T]) Add(values ...T)

Add value to set

func (Set[T]) Clone

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

Clone return a copy of set

func (Set[T]) Contain

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

Contain checks if set contains value or not

func (Set[T]) ContainAll

func (s Set[T]) ContainAll(other Set[T]) bool

Contain checks if set contains other set

func (Set[T]) Delete

func (s Set[T]) Delete(values ...T)

Delete value of set

func (Set[T]) Equal

func (s Set[T]) Equal(other Set[T]) bool

Equal checks if two set has same elements or not

func (Set[T]) Intersection

func (s Set[T]) Intersection(other Set[T]) Set[T]

Intersection creates a new set whose element both be contained in set s and other

func (Set[T]) IsEmpty

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

IsEmpty checks the set is empty or not

func (Set[T]) Iterate

func (s Set[T]) Iterate(fn func(value T))

Iterate call function by every element of set

func (Set[T]) Size

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

Size get the number of elements in set

func (Set[T]) Union

func (s Set[T]) Union(other Set[T]) Set[T]

Union creates a new set contain all element of set s and other

func (Set[T]) Values

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

Values return all values of set

Jump to

Keyboard shortcuts

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