util

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Int64Set

type Int64Set map[int64]struct{}

Int64Set is the primary type that represents a set

func BuildInt64SetFromChan

func BuildInt64SetFromChan(source <-chan int64) Int64Set

BuildInt64SetFromChan constructs a new Int64Set from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertInt64Set

func ConvertInt64Set(values ...interface{}) (Int64Set, bool)

ConvertInt64Set constructs a new set containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly.

func NewInt64Set

func NewInt64Set(values ...int64) Int64Set

NewInt64Set creates and returns a reference to an empty set.

func (Int64Set) Add

func (set Int64Set) Add(i ...int64) Int64Set

Add adds items to the current set, returning the modified set.

func (Int64Set) Append

func (set Int64Set) Append(more ...int64) Int64Set

Union returns a new set with all items in both sets.

func (Int64Set) Cardinality

func (set Int64Set) Cardinality() int

Cardinality returns how many items are currently in the set. This is a synonym for Size.

func (*Int64Set) Clear

func (set *Int64Set) Clear()

Clear clears the entire set to be the empty set.

func (Int64Set) Clone

func (set Int64Set) Clone() Int64Set

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (Int64Set) Contains

func (set Int64Set) Contains(i int64) bool

Contains determines if a given item is already in the set.

func (Int64Set) ContainsAll

func (set Int64Set) ContainsAll(i ...int64) bool

ContainsAll determines if the given items are all in the set

func (Int64Set) CountBy

func (set Int64Set) CountBy(predicate func(int64) bool) (result int)

CountBy gives the number elements of Int64Set that return true for the passed predicate.

func (Int64Set) Difference

func (set Int64Set) Difference(other Int64Set) Int64Set

Difference returns a new set with items in the current set but not in the other set

func (Int64Set) Equals

func (set Int64Set) Equals(other Int64Set) bool

Equals 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. Order of items is not relevent for sets to be equal.

func (Int64Set) Exists

func (set Int64Set) Exists(fn func(int64) bool) bool

Exists applies a predicate function to every element in the set. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (Int64Set) Filter

func (set Int64Set) Filter(fn func(int64) bool) Int64Set

Filter returns a new Int64Set whose elements return true for func. The original set is not modified

func (Int64Set) FlatMap

func (set Int64Set) FlatMap(fn func(int64) []int64) Int64Set

FlatMap returns a new Int64Set by transforming every element with a function fn that returns zero or more items in a slice. The resulting list may have a different size to the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64Set) Forall

func (set Int64Set) Forall(fn func(int64) bool) bool

Forall applies a predicate function to every element in the set. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (Int64Set) Foreach

func (set Int64Set) Foreach(fn func(int64))

Foreach iterates over int64Set and executes the passed func against each element.

func (Int64Set) Intersect

func (set Int64Set) Intersect(other Int64Set) Int64Set

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

func (Int64Set) IsEmpty

func (set Int64Set) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (Int64Set) IsSequence

func (set Int64Set) IsSequence() bool

IsSequence returns true for lists.

func (Int64Set) IsSet

func (set Int64Set) IsSet() bool

IsSet returns false for lists.

func (Int64Set) IsSubset

func (set Int64Set) IsSubset(other Int64Set) bool

IsSubset determines if every item in the other set is in this set.

func (Int64Set) IsSuperset

func (set Int64Set) IsSuperset(other Int64Set) bool

IsSuperset determines if every item of this set is in the other set.

func (Int64Set) Map

func (set Int64Set) Map(fn func(int64) int64) Int64Set

Map returns a new Int64Set by transforming every element with a function fn. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64Set) Max

func (list Int64Set) Max() (result int64)

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (Int64Set) MaxBy

func (set Int64Set) MaxBy(less func(int64, int64) bool) int64

MaxBy returns an element of Int64Set containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (Int64Set) Min

func (list Int64Set) Min() int64

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (Int64Set) MinBy

func (set Int64Set) MinBy(less func(int64, int64) bool) int64

MinBy returns an element of Int64Set containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (Int64Set) NonEmpty

func (set Int64Set) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (Int64Set) Partition

func (set Int64Set) Partition(p func(int64) bool) (Int64Set, Int64Set)

Partition returns two new int64Sets whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original list. The original set is not modified

func (Int64Set) Remove

func (set Int64Set) Remove(i int64)

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

func (Int64Set) Send

func (set Int64Set) Send() <-chan int64

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed

func (Int64Set) Size

func (set Int64Set) Size() int

Size returns how many items are currently in the set. This is a synonym for Cardinality.

func (Int64Set) Sum

func (set Int64Set) Sum() int64

Sum returns the sum of all the elements in the set.

func (Int64Set) SymmetricDifference

func (set Int64Set) SymmetricDifference(other Int64Set) Int64Set

SymmetricDifference returns a new set with items in the current set or the other set but not in both.

func (Int64Set) ToInterfaceSlice

func (set Int64Set) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current set as a slice of arbitrary type.

func (Int64Set) ToSlice

func (set Int64Set) ToSlice() []int64

ToSlice returns the elements of the current set as a slice.

func (Int64Set) Union

func (set Int64Set) Union(other Int64Set) Int64Set

Union returns a new set with all items in both sets.

type StringAnyMap

type StringAnyMap map[string]interface{}

StringAnyMap is the primary type that represents a map

func NewStringAnyMap

func NewStringAnyMap(kv ...StringAnyTuple) StringAnyMap

NewStringAnyMap creates and returns a reference to a map, optionally containing some items.

func NewStringAnyMap1

func NewStringAnyMap1(k string, v interface{}) StringAnyMap

NewStringAnyMap creates and returns a reference to a map containing one item.

func (*StringAnyMap) Clear

func (mm *StringAnyMap) Clear()

Clear clears the entire map.

func (StringAnyMap) Clone

func (mm StringAnyMap) Clone() StringAnyMap

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (StringAnyMap) ContainsAllKeys

func (mm StringAnyMap) ContainsAllKeys(kk ...string) bool

ContainsAllKeys determines if the given items are all in the map.

func (StringAnyMap) ContainsKey

func (mm StringAnyMap) ContainsKey(k string) bool

ContainsKey determines if a given item is already in the map.

func (StringAnyMap) DropWhere

func (mm StringAnyMap) DropWhere(fn func(string, interface{}) bool) StringAnyTuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map.

func (StringAnyMap) Exists

func (mm StringAnyMap) Exists(fn func(string, interface{}) bool) bool

Exists applies a predicate function to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (StringAnyMap) Filter

func (mm StringAnyMap) Filter(fn func(string, interface{}) bool) StringAnyMap

Filter applies a predicate function to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified

func (StringAnyMap) Find

func (mm StringAnyMap) Find(fn func(string, interface{}) bool) (StringAnyTuple, bool)

Find returns the first interface{} that returns true for some function. False is returned if none match. The original map is not modified

func (StringAnyMap) FlatMap

func (mm StringAnyMap) FlatMap(fn func(string, interface{}) []StringAnyTuple) StringAnyMap

FlatMap returns a new AnyMap by transforming every element with a function fn that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringAnyMap) Forall

func (mm StringAnyMap) Forall(fn func(string, interface{}) bool) bool

Forall applies a predicate function to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (StringAnyMap) Foreach

func (mm StringAnyMap) Foreach(fn func(string, interface{}))

Foreach applies a function to every element in the map. The function can safely alter the values via side-effects.

func (StringAnyMap) Get

func (mm StringAnyMap) Get(k string) (interface{}, bool)

Get returns one of the items in the map, if present.

func (StringAnyMap) IsEmpty

func (mm StringAnyMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (StringAnyMap) Keys

func (mm StringAnyMap) Keys() []string

Keys returns the keys of the current map as a slice.

func (StringAnyMap) Map

func (mm StringAnyMap) Map(fn func(string, interface{}) (string, interface{})) StringAnyMap

Map returns a new AnyMap by transforming every element with a function fn. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringAnyMap) NonEmpty

func (mm StringAnyMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (StringAnyMap) Partition

func (mm StringAnyMap) Partition(fn func(string, interface{}) bool) (matching StringAnyMap, others StringAnyMap)

Partition applies a predicate function to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified

func (StringAnyMap) Pop

func (mm StringAnyMap) Pop(k string) (interface{}, bool)

Pop removes a single item from the map, returning the value present until removal.

func (StringAnyMap) Put

func (mm StringAnyMap) Put(k string, v interface{}) bool

Put adds an item to the current map, replacing interface{} prior value.

func (StringAnyMap) Remove

func (mm StringAnyMap) Remove(k string)

Remove a single item from the map.

func (StringAnyMap) Size

func (mm StringAnyMap) Size() int

Size returns how minterface{} items are currently in the map. This is a synonym for Len.

func (StringAnyMap) ToSlice

func (mm StringAnyMap) ToSlice() []StringAnyTuple

ToSlice returns the key/value pairs as a slice

func (StringAnyMap) Values

func (mm StringAnyMap) Values() []interface{}

Values returns the values of the current map as a slice.

type StringAnyTuple

type StringAnyTuple struct {
	Key string
	Val interface{}
}

StringAnyTuple represents a key/value pair.

type StringAnyTuples

type StringAnyTuples []StringAnyTuple

StringAnyTuples can be used as a builder for unmodifiable maps.

func (StringAnyTuples) Append1

func (ts StringAnyTuples) Append1(k string, v interface{}) StringAnyTuples

func (StringAnyTuples) Append2

func (ts StringAnyTuples) Append2(k1 string, v1 interface{}, k2 string, v2 interface{}) StringAnyTuples

func (StringAnyTuples) Append3

func (ts StringAnyTuples) Append3(k1 string, v1 interface{}, k2 string, v2 interface{}, k3 string, v3 interface{}) StringAnyTuples

type StringList

type StringList []string

StringList is a slice of type string. Use it where you would use []string. To add items to the list, simply use the normal built-in append function. List values follow a similar pattern to Scala Lists and LinearSeqs in particular. Importantly, *none of its methods ever mutate a list*; they merely return new lists where required. When a list needs mutating, use normal Go slice operations, e.g. *append()*. For comparison with Scala, see e.g. http://www.scala-lang.org/api/2.11.7/#scala.collection.LinearSeq

func BuildStringListFromChan

func BuildStringListFromChan(source <-chan string) StringList

BuildStringListFromChan constructs a new StringList from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertStringList

func ConvertStringList(values ...interface{}) (StringList, bool)

ConvertStringList constructs a new list containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned list will contain all the values that were correctly converted.

func NewStringList

func NewStringList(values ...string) StringList

NewStringList constructs a new list containing the supplied values, if any.

func (StringList) Clone

func (list StringList) Clone() StringList

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (StringList) Contains

func (list StringList) Contains(v string) bool

Contains determines if a given item is already in the list.

func (StringList) ContainsAll

func (list StringList) ContainsAll(i ...string) bool

ContainsAll determines if the given items are all in the list. This is potentially a slow method and should only be used rarely.

func (StringList) CountBy

func (list StringList) CountBy(predicate func(string) bool) (result int)

CountBy gives the number elements of StringList that return true for the passed predicate.

func (StringList) DistinctBy

func (list StringList) DistinctBy(equal func(string, string) bool) StringList

DistinctBy returns a new StringList whose elements are unique, where equality is defined by a passed func.

func (StringList) Drop

func (list StringList) Drop(n int) StringList

Drop returns a slice of StringList without the leading n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

func (StringList) DropLast

func (list StringList) DropLast(n int) StringList

DropLast returns a slice of StringList without the trailing n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

func (StringList) DropWhile

func (list StringList) DropWhile(p func(string) bool) StringList

DropWhile returns a new StringList containing the trailing elements of the source list. Whilst the predicate p returns true, elements are excluded from the result. Once predicate p returns false, all remaining elemense are added.

func (StringList) Equals

func (list StringList) Equals(other StringList) bool

Equals determines if two lists are equal to each other. If they both are the same size and have the same items in the same order, they are considered equal. Order of items is not relevent for sets to be equal.

func (StringList) Exists

func (list StringList) Exists(fn func(string) bool) bool

Exists verifies that one or more elements of StringList return true for the passed func.

func (StringList) Filter

func (list StringList) Filter(fn func(string) bool) StringList

Filter returns a new StringList whose elements return true for func. The original list is not modified

func (StringList) Find

func (list StringList) Find(fn func(string) bool) (string, bool)

Find returns the first string that returns true for some function. False is returned if none match.

func (StringList) FlatMap

func (list StringList) FlatMap(fn func(string) []string) StringList

FlatMap returns a new StringList by transforming every element with a function fn that returns zero or more items in a slice. The resulting list may have a different size to the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringList) Forall

func (list StringList) Forall(fn func(string) bool) bool

Forall verifies that all elements of StringList return true for the passed func.

func (StringList) Foreach

func (list StringList) Foreach(fn func(string))

Foreach iterates over StringList and executes the passed func against each element.

func (StringList) Get

func (list StringList) Get(i int) string

Get gets the specified element in the list. Panics if the index is out of range. The simple list is a dressed-up slice and normal slice operations will also work.

func (StringList) Head

func (list StringList) Head() string

Head gets the first element in the list. Head plus Tail include the whole list. Head is the opposite of Last. Panics if list is empty

func (StringList) IndexWhere

func (list StringList) IndexWhere(p func(string) bool) int

IndexWhere finds the index of the first element satisfying some predicate. If none exists, -1 is returned.

func (StringList) IndexWhere2

func (list StringList) IndexWhere2(p func(string) bool, from int) int

IndexWhere2 finds the index of the first element satisfying some predicate at or after some start index. If none exists, -1 is returned.

func (StringList) Init

func (list StringList) Init() StringList

Init gets everything except the last. Init plus Last include the whole list. Init is the opposite of Tail. Panics if list is empty

func (StringList) IsEmpty

func (list StringList) IsEmpty() bool

IsEmpty tests whether StringList is empty.

func (StringList) IsSequence

func (list StringList) IsSequence() bool

IsSequence returns true for lists.

func (StringList) IsSet

func (list StringList) IsSet() bool

IsSet returns false for lists.

func (StringList) Last

func (list StringList) Last() string

Last gets the last element in the list. Init plus Last include the whole list. Last is the opposite of Head. Panics if list is empty

func (StringList) LastIndexWhere

func (list StringList) LastIndexWhere(p func(string) bool) int

LastIndexWhere finds the index of the last element satisfying some predicate. If none exists, -1 is returned.

func (StringList) LastIndexWhere2

func (list StringList) LastIndexWhere2(p func(string) bool, before int) int

LastIndexWhere2 finds the index of the last element satisfying some predicate at or before some start index. If none exists, -1 is returned.

func (StringList) Len

func (list StringList) Len() int

Len returns the number of items in the list - an alias of Size(). This is one of the three methods in the standard sort.Interface.

func (StringList) Map

func (list StringList) Map(fn func(string) string) StringList

Map returns a new StringList by transforming every element with a function fn. The resulting list is the same size as the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringList) Max

func (list StringList) Max() (result string)

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (StringList) MaxBy

func (list StringList) MaxBy(less func(string, string) bool) string

MaxBy returns an element of StringList containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (StringList) Min

func (list StringList) Min() string

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (StringList) MinBy

func (list StringList) MinBy(less func(string, string) bool) string

MinBy returns an element of StringList containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (StringList) NonEmpty

func (list StringList) NonEmpty() bool

NonEmpty tests whether StringList is empty.

func (StringList) Partition

func (list StringList) Partition(p func(string) bool) (StringList, StringList)

Partition returns two new stringLists whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original list. The original list is not modified

func (StringList) Reverse

func (list StringList) Reverse() StringList

Reverse returns a copy of StringList with all elements in the reverse order.

func (StringList) Send

func (list StringList) Send() <-chan string

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed

func (StringList) Shuffle

func (list StringList) Shuffle() StringList

Shuffle returns a shuffled copy of StringList, using a version of the Fisher-Yates shuffle.

func (StringList) Size

func (list StringList) Size() int

Size returns the number of items in the list - an alias of Len().

func (StringList) SortBy

func (list StringList) SortBy(less func(i, j string) bool) StringList

SortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned.

func (StringList) Sorted

func (list StringList) Sorted() StringList

Sorted alters the list so that the elements are sorted by their natural ordering.

func (StringList) StableSortBy

func (list StringList) StableSortBy(less func(i, j string) bool) StringList

StableSortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned. The algorithm keeps the original order of equal elements.

func (StringList) StableSorted

func (list StringList) StableSorted() StringList

StableSorted alters the list so that the elements are sorted by their natural ordering.

func (StringList) Swap

func (list StringList) Swap(i, j int)

Swap exchanges two elements, which is necessary during sorting etc. This is one of the three methods in the standard sort.Interface.

func (StringList) Tail

func (list StringList) Tail() StringList

Tail gets everything except the head. Head plus Tail include the whole list. Tail is the opposite of Init. Panics if list is empty

func (StringList) Take

func (list StringList) Take(n int) StringList

Take returns a slice of StringList containing the leading n elements of the source list. If n is greater than the size of the list, the whole original list is returned.

func (StringList) TakeLast

func (list StringList) TakeLast(n int) StringList

TakeLast returns a slice of StringList containing the trailing n elements of the source list. If n is greater than the size of the list, the whole original list is returned.

func (StringList) TakeWhile

func (list StringList) TakeWhile(p func(string) bool) StringList

TakeWhile returns a new StringList containing the leading elements of the source list. Whilst the predicate p returns true, elements are added to the result. Once predicate p returns false, all remaining elemense are excluded.

func (StringList) ToInterfaceSlice

func (list StringList) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current list as a slice of arbitrary type.

type StringSet

type StringSet map[string]struct{}

StringSet is the primary type that represents a set

func BuildStringSetFromChan

func BuildStringSetFromChan(source <-chan string) StringSet

BuildStringSetFromChan constructs a new StringSet from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertStringSet

func ConvertStringSet(values ...interface{}) (StringSet, bool)

ConvertStringSet constructs a new set containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly.

func NewStringSet

func NewStringSet(values ...string) StringSet

NewStringSet creates and returns a reference to an empty set.

func (StringSet) Add

func (set StringSet) Add(i ...string) StringSet

Add adds items to the current set, returning the modified set.

func (StringSet) Append

func (set StringSet) Append(more ...string) StringSet

Union returns a new set with all items in both sets.

func (StringSet) Cardinality

func (set StringSet) Cardinality() int

Cardinality returns how many items are currently in the set. This is a synonym for Size.

func (*StringSet) Clear

func (set *StringSet) Clear()

Clear clears the entire set to be the empty set.

func (StringSet) Clone

func (set StringSet) Clone() StringSet

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (StringSet) Contains

func (set StringSet) Contains(i string) bool

Contains determines if a given item is already in the set.

func (StringSet) ContainsAll

func (set StringSet) ContainsAll(i ...string) bool

ContainsAll determines if the given items are all in the set

func (StringSet) CountBy

func (set StringSet) CountBy(predicate func(string) bool) (result int)

CountBy gives the number elements of StringSet that return true for the passed predicate.

func (StringSet) Difference

func (set StringSet) Difference(other StringSet) StringSet

Difference returns a new set with items in the current set but not in the other set

func (StringSet) Equals

func (set StringSet) Equals(other StringSet) bool

Equals 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. Order of items is not relevent for sets to be equal.

func (StringSet) Exists

func (set StringSet) Exists(fn func(string) bool) bool

Exists applies a predicate function to every element in the set. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (StringSet) Filter

func (set StringSet) Filter(fn func(string) bool) StringSet

Filter returns a new StringSet whose elements return true for func. The original set is not modified

func (StringSet) FlatMap

func (set StringSet) FlatMap(fn func(string) []string) StringSet

FlatMap returns a new StringSet by transforming every element with a function fn that returns zero or more items in a slice. The resulting list may have a different size to the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringSet) Forall

func (set StringSet) Forall(fn func(string) bool) bool

Forall applies a predicate function to every element in the set. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (StringSet) Foreach

func (set StringSet) Foreach(fn func(string))

Foreach iterates over stringSet and executes the passed func against each element.

func (StringSet) Intersect

func (set StringSet) Intersect(other StringSet) StringSet

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

func (StringSet) IsEmpty

func (set StringSet) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (StringSet) IsSequence

func (set StringSet) IsSequence() bool

IsSequence returns true for lists.

func (StringSet) IsSet

func (set StringSet) IsSet() bool

IsSet returns false for lists.

func (StringSet) IsSubset

func (set StringSet) IsSubset(other StringSet) bool

IsSubset determines if every item in the other set is in this set.

func (StringSet) IsSuperset

func (set StringSet) IsSuperset(other StringSet) bool

IsSuperset determines if every item of this set is in the other set.

func (StringSet) Map

func (set StringSet) Map(fn func(string) string) StringSet

Map returns a new StringSet by transforming every element with a function fn. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringSet) Max

func (list StringSet) Max() (result string)

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (StringSet) MaxBy

func (set StringSet) MaxBy(less func(string, string) bool) string

MaxBy returns an element of StringSet containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (StringSet) Min

func (list StringSet) Min() string

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (StringSet) MinBy

func (set StringSet) MinBy(less func(string, string) bool) string

MinBy returns an element of StringSet containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (StringSet) NonEmpty

func (set StringSet) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (StringSet) Partition

func (set StringSet) Partition(p func(string) bool) (StringSet, StringSet)

Partition returns two new stringSets whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original list. The original set is not modified

func (StringSet) Remove

func (set StringSet) Remove(i string)

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

func (StringSet) Send

func (set StringSet) Send() <-chan string

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed

func (StringSet) Size

func (set StringSet) Size() int

Size returns how many items are currently in the set. This is a synonym for Cardinality.

func (StringSet) SymmetricDifference

func (set StringSet) SymmetricDifference(other StringSet) StringSet

SymmetricDifference returns a new set with items in the current set or the other set but not in both.

func (StringSet) ToInterfaceSlice

func (set StringSet) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current set as a slice of arbitrary type.

func (StringSet) ToSlice

func (set StringSet) ToSlice() []string

ToSlice returns the elements of the current set as a slice.

func (StringSet) Union

func (set StringSet) Union(other StringSet) StringSet

Union returns a new set with all items in both sets.

Jump to

Keyboard shortcuts

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