set

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element interface {
	Name() string
}

Element is an interface for set elements

type Set

type Set map[string]Element

Set is type for a set of elements identified by their names

func New

func New() Set

New is a constructor for an empty set

func (Set) Any

func (set Set) Any() Element

Any returns an arbitrary element of a set

func (Set) Contains

func (set Set) Contains(element Element) bool

Contains checks if set contains an element with given name

func (Set) Delete

func (set Set) Delete(element Element)

Delete deletes an element with a given name from a set

func (Set) Empty

func (set Set) Empty() bool

Empty checks if set is nil or empty

func (Set) Insert

func (set Set) Insert(element Element)

Insert inserts an element with a given name to a set

func (Set) InsertAll

func (set Set) InsertAll(other Set)

InsertAll inserts all elements from an other set to a given set

func (Set) SafeInsert

func (set Set) SafeInsert(element Element) error

SafeInsert inserts element to a set If the same element was already in the set nothing is done If element with the same name already was in the set an error is returned

func (Set) SafeInsertAll

func (set Set) SafeInsertAll(other Set) error

SafeInsertAll inserts all elements from an other set to a given set If at least one of the elements in the given set has the same name as of one the elements of the given set and is different from it an error is returned an the given set remains unchanged

func (Set) Size

func (set Set) Size() int

Size returns number of elements in a set

func (Set) ToArray

func (set Set) ToArray() []Element

ToArray converts a set to an array sorted by elements names

Jump to

Keyboard shortcuts

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