sets

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Empty

type Empty struct{}

Empty is public since it is used by some internal API objects for conversions between external string arrays and internal sets, and conversion logic requires public types today.

type Set

type Set[T comparable] map[T]Empty

Set is a set of the same type elements, implemented via map[comparable]struct{} for minimal memory consumption.

func New

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

New creates a new Set from a list of values.

func Remove

func Remove[T comparable](a Set[T], sets ...Set[T]) Set[T]

Remove returns a new set with all items from the input set that are not in the other set.

func RemoveExtensions

func RemoveExtensions(items Set[string], sets ...Set[string]) Set[string]

RemoveExtensions returns a new set with all items from the input set that are not an extension of another item in the set or any of the additional sets. We consider a string a prefix of another string if the other string starts with the first string followed by a period or an opening square bracket.

func RemovePrefixes

func RemovePrefixes(items Set[string], sets ...Set[string]) Set[string]

RemovePrefixes returns a new set with all items from the input set that are not a prefix of another item in the set or any of the additional sets. We consider a string a prefix of another string if the other string starts with the first string followed by a period or an opening square bracket.

func Union

func Union[T comparable](sets ...Set[T]) Set[T]

Union returns a new set with all items from both sets.

func (Set[T]) Delete

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

Delete removes items from the set.

func (Set[T]) Has

func (s Set[T]) Has(items ...T) bool

Has returns true if the set contains the items.

func (Set[T]) Insert

func (s Set[T]) Insert(items ...T)

Insert adds items to the set.

func (Set[T]) UnsortedList

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

UnsortedList returns the elements of the set as a list.

Jump to

Keyboard shortcuts

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