set

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package set implements a set type for strings and integers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Int

type Int map[int]signal

Int is a set of ints. Remember to initialize with make(Int) or Int{}

func FromInts

func FromInts(ints ...int) Int

FromInts creates a set from ints

func (Int) Add

func (s Int) Add(keys ...int)

Add a key or key(s) to the set, in-place. Don't call on a nil set.

func (Int) Contains

func (s Int) Contains(key int) bool

Contains shows whether a given key is in the Int.

func (Int) Copy

func (s Int) Copy() Int

Copy copies the set of ints.

func (Int) Delete

func (s Int) Delete(keys ...int)

Delete a key or keys from the set, in-place.

func (Int) Difference

func (s Int) Difference(ints ...Int) (difference Int)

Difference returns the items in the reciever but not any other arguments

func (Int) Equal

func (s Int) Equal(other Int) bool

Equal shows whether two Ints are equal; i.e, they contain the same items.

func (Int) Filter

func (s Int) Filter(f func(int) bool) Int

Filter applies a filtering function across the set, returning a set containing x where f(x) is true.

func (Int) IUnion

func (s Int) IUnion(ints ...Int)

IUnion modifies the Int in place rather than returning a copy.

func (Int) Intersection

func (s Int) Intersection(ints ...Int) (intersection Int)

Intersection returns a new set containing the intersection of the ints;

func (Int) IsDisjoint

func (s Int) IsDisjoint(other Int) bool

IsDisjoint returns true if s∩other == Ø; that is, s shares no elements with other. Note that the empty set is disjoint with everything.

func (Int) IsProperSubset

func (s Int) IsProperSubset(other Int) bool

IsProperSubset returns true if every s ⊂ other: every key in s is also in other and s != other

func (Int) IsProperSuperset

func (s Int) IsProperSuperset(other Int) bool

IsProperSuperset returns true if other ⊂ s; every key in other is also in s and s != other

func (Int) IsSubset

func (s Int) IsSubset(other Int) bool

IsSubset returns true if s⊆other; every key in s is also in other

func (Int) IsSuperset

func (s Int) IsSuperset(other Int) bool

IsSuperset returns true if other ⊆ s; every key in other is also in s

func (Int) Map

func (s Int) Map(f func(int) int) Int

Map a function f(x) across the set, returning a new set containing f(x) for all x in the set.

func (Int) Pop

func (s Int) Pop() (k int, more bool)

Pop an arbitrary element from the set. Returns 0, false if no more elements remain. No order (or lack of order) is guaranteed.

func (Int) Reduce

func (s Int) Reduce(f func(int, int) int) (int, bool)

Reduce applies a reducing function across the set. It will return (0, false) for a set with zero entries.

func (Int) Remove

func (s Int) Remove(key int) bool

Remove removes a key from the set, returning the presence of the key.

func (Int) Sorted

func (s Int) Sorted() []int

Sorted returns a slice containing the sorted keys of the set in the usual order.

func (Int) ToSlice

func (s Int) ToSlice() []int

ToSlice returns a slice containing the keys of a set. No order is guaranteed.

func (Int) Union

func (s Int) Union(ints ...Int) (union Int)

Union returns a new set containing the union of the int sets.

func (Int) XOR

func (s Int) XOR(other Int) Int

XOR returns the keys in one set but not the other.

type String

type String map[string]signal

String is a set of strings. Remember to initialize with make or String{}

func FromStrings

func FromStrings(strings ...string) String

FromStrings creates a set from strings

func (String) Add

func (s String) Add(keys ...string)

Add a key or key(s) to the set, in-place. Don't call on a nil set.

func (String) Contains

func (s String) Contains(key string) bool

Contains returns true if the given key is in the set.

func (String) Copy

func (s String) Copy() String

Copy copies the set of strings.

func (String) Difference

func (s String) Difference(strings ...String) (difference String)

Difference returns the items in the reciever but not any other arguments

func (String) Equal

func (s String) Equal(other String) bool

Equal shows whether two Strings are equal; i.e, they contain the same items.

func (String) Filter

func (s String) Filter(f func(string) bool) String

Filter applies a filtering function across the set, returning a set containing x where f(x) is true.

func (String) IUnion

func (s String) IUnion(strings ...String)

IUnion modifies the StringSet in place rather than returning a copy.

func (String) Intersection

func (s String) Intersection(strings ...String) (intersection String)

Intersection returns a new set containing the intersection of the strings;

func (String) IsDisjoint

func (s String) IsDisjoint(other String) bool

IsDisjoint returns true if s shared no elements with other. Note that the empty set is disjoint with everything.

func (String) IsProperSubset

func (s String) IsProperSubset(other String) bool

IsProperSubset returns true if every key in s is also in other and s != other

func (String) IsProperSuperset

func (s String) IsProperSuperset(other String) bool

IsProperSuperset returns true if every key in other is also in s and s != other

func (String) IsSubset

func (s String) IsSubset(other String) bool

IsSubset returns true if every key in s is also in other

func (String) IsSuperset

func (s String) IsSuperset(other String) bool

IsSuperset returns true if every key in other is also in s

func (String) Map

func (s String) Map(f func(string) string) String

Map a function f(x) across the set, returning a new set containing f(x) for all x in the set.

func (String) Pop

func (s String) Pop() (k string, more bool)

Pop an arbitrary element from the set. Returns "", false if no more elements remain. No order, or lack of order, is guaranteed.

func (String) Reduce

func (s String) Reduce(f func(string, string) string) (string, bool)

Reduce applies a reducing function across the set. It will return (0, false) for a set with zero entries.

func (String) Remove

func (s String) Remove(key string) bool

Remove removes a key from the set, returning the presence of the key.

func (String) Sorted

func (s String) Sorted() []string

Sorted returns a slice containing the keys of the set in lexigraphic order.

func (String) ToSlice

func (s String) ToSlice() []string

ToSlice returns a slice containing the keys of a set. No order is guaranteed.

func (String) Union

func (s String) Union(strings ...String) (union String)

Union returns a new set containing the union of the string sets.

func (String) XOR

func (s String) XOR(other String) String

XOR returns the keys in one set but not the other.

Jump to

Keyboard shortcuts

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