set

package
v2.2.105 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 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 Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

Set represents a set. It is implemented as a thin wrapper over a map with a zero sized value.

func FromValues

func FromValues[T comparable](values []T) Set[T]

FromValues creates a new set from the given values. If the provided values contain duplicates, the set will only contain one of instance of each value.

func WithCapacity

func WithCapacity[T comparable](cap int) Set[T]

WithCapacity creates a new set with the given capacity.

func (*Set[T]) Add

func (s *Set[T]) Add(value T) bool

Add adds the given value to the set. Returns true, iff the value was not part of the set and was actually added.

func (*Set[T]) Contains

func (s *Set[T]) Contains(value T) bool

Contains returns true iff the value is part of the Set.

func (*Set[T]) Len

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

Len returns the number of values in the Set.

func (*Set[T]) Remove

func (s *Set[T]) Remove(value T) bool

Remove removes the given value from the set. Returns true, iff the value was part of the set and got removed.

Jump to

Keyboard shortcuts

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