set

package module
v6.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2018 License: MIT Imports: 3 Imported by: 51

Documentation

Overview

Package set provides set datastructure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapstructureDecodeHookFromListToStrSet

func MapstructureDecodeHookFromListToStrSet(fromType, toType reflect.Type, from interface{}) (interface{}, error)

MapstructureDecodeHookFromListToStrSet decodes []interface{} to StrSet. This function implements the mapstructure.DecodeHookFuncType interface. https://godoc.org/github.com/mitchellh/mapstructure#DecodeHookFuncType

Types

type StrSet

type StrSet map[string]struct{}

StrSet represents a string set.

func NewStrSet

func NewStrSet(args ...string) StrSet

NewStrSet returns a StrSet.

func (*StrSet) Add

func (set *StrSet) Add(k string) error

Add adds a string to the set. An error is returned when set is nil.

func (*StrSet) AddSet

func (set *StrSet) AddSet(other StrSet) error

AddSet adds a StrSet to the set. An error is returned when set is nil.

func (*StrSet) AddSets

func (set *StrSet) AddSets(others ...StrSet) error

AddSets adds StrSets to the set. An error is returned when set is nil.

func (*StrSet) Adds

func (set *StrSet) Adds(args ...string) error

Adds adds strings to the set. An error is returned when set is nil.

func (StrSet) Clear

func (set StrSet) Clear()

Clear removes all elements. If set is nil, nothing happens.

func (StrSet) Clone

func (set StrSet) Clone() StrSet

Clone returns a new StrSet which has same elements. If set is nil, new empty set is returned.

func (StrSet) Has

func (set StrSet) Has(k string) bool

Has returns whether a given string is included in the set. If set is nil, false is returned.

func (*StrSet) HasAll

func (set *StrSet) HasAll(args ...string) bool

HasAll returns whether all given strings are included in the set. If set is nil, false is returned.

func (*StrSet) HasAny

func (set *StrSet) HasAny(args ...string) bool

HasAny returns whether some given strings are included in the set. If set is nil, false is returned.

func (StrSet) MarshalJSON

func (set StrSet) MarshalJSON() ([]byte, error)

MarshalJSON is the implementation of the json.Marshaler interface.

func (StrSet) Remove

func (set StrSet) Remove(k string)

Remove removes a string from the set. If set is nil, nothing happens.

func (StrSet) Removes

func (set StrSet) Removes(args ...string)

Removes removes strings from the set. If set is nil, nothing happens.

func (StrSet) ToList

func (set StrSet) ToList() []string

ToList returns a list composed of elements of the set. If set is nil, an empty list is returned.

func (StrSet) ToMap

func (set StrSet) ToMap(deep bool) map[string]struct{}

ToMap returns a map whose keys are elements of the set. If the parameter 'deep' is true, this method returns a new map. If the parameter 'deep' is false, this method returns the map which the set has internally. If set is nil, an empty map is returned.

func (*StrSet) UnmarshalJSON

func (set *StrSet) UnmarshalJSON(b []byte) error

UnmarshalJSON is the implementation of the json.Unmarshaler interface. An error is returned when set is nil.

Jump to

Keyboard shortcuts

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