set

package
v0.0.0-...-4a5ca7f Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashSet

type HashSet[T comparable] map[T]struct{}

HashSet is unordered set of unique elements. It's built on top of map, so you can iterate over set like over map:

hashSet := containers.NewHashSet[string]()
for element := range hashSet {
	fmt.Println(element)
}

func New

func New[T comparable](elements ...T) HashSet[T]

func (HashSet[T]) Add

func (s HashSet[T]) Add(element T)

Add adds element to the set.

func (HashSet[T]) Contains

func (s HashSet[T]) Contains(element T) bool

Contains checks if element is in the set.

func (HashSet[T]) Remove

func (s HashSet[T]) Remove(e T)

Remove removes element from the set.

func (HashSet[T]) Slice

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

Slice return elements of the set as slice with the same type. Order of elements is not guaranteed.

Jump to

Keyboard shortcuts

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