stringset

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: Apache-2.0 Imports: 1 Imported by: 9

Documentation

Overview

Package stringset implements a basic set of strings

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	// contains filtered or unexported fields
}

Data represent a set of strings

func From

func From(strings []string) *Data

From create a empty set of strings given a slice of strings

func FromKeys

func FromKeys[T any](v map[string]T) *Data

FromKeys create a string set from the keys of a map

func New

func New() *Data

New create a new empty set of strings

func (*Data) Delete

func (set *Data) Delete(key string)

Delete deletes a string from the set. If the string doesn't exist this is a no-op

func (*Data) Eq

func (set *Data) Eq(other *Data) bool

Eq compares two string sets for equality

func (*Data) Has

func (set *Data) Has(key string) bool

Has checks if a string is in the set or not

func (*Data) Intersect

func (set *Data) Intersect(other *Data) *Data

Intersect returns a new set containing all the elements that are present in both the set and the argument (set intersections).

func (*Data) Len

func (set *Data) Len() int

Len returns the map of the set

func (*Data) Put

func (set *Data) Put(key string)

Put a string in the set

func (*Data) Subtract

func (set *Data) Subtract(other *Data) *Data

Subtract returns a new set containing all the elements that are present in the set but not in the argument (set difference).

func (*Data) ToList

func (set *Data) ToList() (result []string)

ToList returns the strings contained in this set as a string slice

func (*Data) ToSortedList

func (set *Data) ToSortedList() []string

ToSortedList returns the string container in this set as a sorted string slice

Jump to

Keyboard shortcuts

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