stringset

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package stringset implements Set operations on strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set map[string]struct{}

Set provides operations like union, intersect, difference on Sets with strings.

func New

func New(a ...string) Set

New creates a set with a elements.

func NewFromStringMap

func NewFromStringMap(items map[string]string) Set

NewFromStringMap collects the keys of a [string]string and returns a Set of strings.

func (Set) Add

func (set Set) Add(s string) bool

Add adds s to the receiver. Returns false if s is already in the receiver.

func (Set) Cardinality

func (set Set) Cardinality() int

Cardinality returns how many items are currently in the set.

func (Set) Clone

func (set Set) Clone() Set

Clone returns a clone of the set. Does NOT clone the underlying elements.

func (Set) Contains

func (set Set) Contains(s string) bool

Contains returns true if s is in the receiver.

func (Set) ContainsAll

func (set Set) ContainsAll(s ...string) bool

ContainsAll returns true if all s's are in the receiver.

func (Set) Difference

func (set Set) Difference(other Set) Set

Difference returns a set with items in the receiver that are not in other.

func (Set) Equal

func (set Set) Equal(other Set) bool

Equal determines if two sets are equal to each other. If they both are the same size and have the same items they are considered equal.

func (Set) Intersect

func (set Set) Intersect(other Set) Set

Intersect returns a new set with items that exist only in both sets.

func (Set) IsSubset

func (set Set) IsSubset(other Set) bool

IsSubset returns true if all items of other are in the receiver.

func (Set) Remove

func (set Set) Remove(i string)

Remove allows the removal of a single item in the set.

func (Set) SymmetricDifference

func (set Set) SymmetricDifference(other Set) Set

SymmetricDifference returns a new set with items of the receiver or other that are not in both sets.

func (Set) ToSlice

func (set Set) ToSlice() []string

ToSlice returns the elements of the receiver as a slice.

func (Set) Union

func (set Set) Union(other Set) Set

Union returns a new set with items of the receiver and items of other.

Jump to

Keyboard shortcuts

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