luci: go.chromium.org/luci/common/data/stringset Index | Files

package stringset

import "go.chromium.org/luci/common/data/stringset"

Package stringset is an exceedingly simple 'set' implementation for strings.

It's not threadsafe, but can be used in place of a simple `map[string]struct{}`

Index

Package Files

doc.go stringset.go

type Set Uses

type Set map[string]struct{}

Set is the base type. make(Set) can be used too.

func New Uses

func New(sizeHint int) Set

New returns a new string Set implementation.

func NewFromSlice Uses

func NewFromSlice(vals ...string) Set

NewFromSlice returns a new string Set implementation, initialized with the values in the provided slice.

func (Set) Add Uses

func (s Set) Add(value string) bool

Add ensures that Set contains value, and returns true if it was added (i.e. it returns false if the Set already contained the value).

func (Set) Del Uses

func (s Set) Del(value string) bool

Del removes value from the set, and returns true if it was deleted (i.e. it returns false if the Set did not already contain the value).

func (Set) Difference Uses

func (s Set) Difference(other Set) Set

Difference returns a new Set which is this set with all elements from other removed (i.e. `self - other`).

`other` must have the same underlying type as the current set, or this will panic.

func (Set) Dup Uses

func (s Set) Dup() Set

Dup returns a duplicate set.

func (Set) Has Uses

func (s Set) Has(value string) bool

Has returns true iff the Set contains value.

func (Set) HasAll Uses

func (s Set) HasAll(values ...string) bool

HasAll returns true iff the Set contains all the given values.

func (Set) Intersect Uses

func (s Set) Intersect(other Set) Set

Intersect returns a new Set which is the intersection of this set with the other set.

`other` must have the same underlying type as the current set, or this will panic.

func (Set) Iter Uses

func (s Set) Iter(cb func(string) bool)

Iter calls `cb` for each item in the set. If `cb` returns false, the iteration stops.

func (Set) Len Uses

func (s Set) Len() int

Len returns the number of items in this set.

func (Set) Peek Uses

func (s Set) Peek() (string, bool)

Peek returns an arbitrary element from the set. If the set was empty, this returns ("", false).

func (Set) Pop Uses

func (s Set) Pop() (string, bool)

Pop removes and returns an arbitrary element from the set and removes it from the set. If the set was empty, this returns ("", false).

func (Set) ToSlice Uses

func (s Set) ToSlice() []string

ToSlice renders this set to a slice of all values.

func (Set) Union Uses

func (s Set) Union(other Set) Set

Union returns a new Set which contains all element from this set, as well as all elements from the other set.

`other` must have the same underlying type as the current set, or this will panic.

Package stringset is imported by 100 packages. Updated 2018-12-17. Refresh now. Tools for package owners.