pie

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2019 License: MIT Imports: 3 Imported by: 67

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Float64s

type Float64s []float64

func (Float64s) All added in v1.4.0

func (ss Float64s) All(fn func(value float64) bool) bool

All will return true if all callbacks return true. It follows the same logic as the all() function in Python.

If the list is empty then true is always returned.

func (Float64s) Any added in v1.4.0

func (ss Float64s) Any(fn func(value float64) bool) bool

Any will return true if any callbacks return true. It follows the same logic as the any() function in Python.

If the list is empty then false is always returned.

func (Float64s) Append added in v1.3.0

func (ss Float64s) Append(elements ...float64) Float64s

Append will return a new slice with the elements appended to the end. It is a wrapper for the internal append(). It is offered as a function so that it can more easily chained.

It is acceptable to provide zero arguments.

func (Float64s) AreSorted

func (ss Float64s) AreSorted() bool

AreSorted will return true if the slice is already sorted. It is a wrapper for sort.Float64sAreSorted.

func (Float64s) AreUnique

func (ss Float64s) AreUnique() bool

AreUnique will return true if the slice contains elements that are all different (unique) from each other.

func (Float64s) Average

func (ss Float64s) Average() float64

Average is the average of all of the elements, or zero if there are no elements.

func (Float64s) Contains

func (ss Float64s) Contains(lookingFor float64) bool

Contains returns true if the element exists in the slice.

When using slices of pointers it will only compare by address, not value.

func (Float64s) Extend added in v1.3.0

func (ss Float64s) Extend(slices ...Float64s) (ss2 Float64s)

Extend will return a new slice with the slices of elements appended to the end.

It is acceptable to provide zero arguments.

func (Float64s) First

func (ss Float64s) First() float64

First returns the first element, or zero. Also see FirstOr().

func (Float64s) FirstOr

func (ss Float64s) FirstOr(defaultValue float64) float64

FirstOr returns the first element or a default value if there are no elements.

func (Float64s) JSONString

func (ss Float64s) JSONString() string

JSONString returns the JSON encoded array as a string.

One important thing to note is that it will treat a nil slice as an empty slice to ensure that the JSON value return is always an array.

func (Float64s) Last

func (ss Float64s) Last() float64

Last returns the last element, or zero. Also see LastOr().

func (Float64s) LastOr

func (ss Float64s) LastOr(defaultValue float64) float64

LastOr returns the last element or a default value if there are no elements.

func (Float64s) Len

func (ss Float64s) Len() int

Len returns the number of elements.

func (Float64s) Max

func (ss Float64s) Max() (max float64)

Max is the maximum value, or zero.

func (Float64s) Min

func (ss Float64s) Min() (min float64)

Min is the minimum value, or zero.

func (Float64s) Reverse

func (ss Float64s) Reverse() Float64s

Reverse returns a new copy of the slice with the elements ordered in reverse. This is useful when combined with Sort to get a descending sort order:

ss.Sort().Reverse()

func (Float64s) Select

func (ss Float64s) Select(condition func(float64) bool) (ss2 Float64s)

Select will return a new slice containing only the elements that return true from the condition. The returned slice may contain zero elements (nil).

Unselect works in the opposite way as Select.

func (Float64s) Shuffle added in v1.6.0

func (ss Float64s) Shuffle(source rand.Source) Float64s

Shuffle returns shuffled slice by your rand.Source

func (Float64s) Sort

func (ss Float64s) Sort() Float64s

Sort works similar to sort.Float64s(). However, unlike sort.Float64s the slice returned will be reallocated as to not modify the input slice.

See Reverse() and AreSorted().

func (Float64s) Sum

func (ss Float64s) Sum() (sum float64)

Sum is the sum of all of the elements.

func (Float64s) ToStrings added in v1.1.0

func (ss Float64s) ToStrings(transform func(float64) string) Strings

ToStrings transforms each element to a string.

func (Float64s) Transform

func (ss Float64s) Transform(fn func(float64) float64) (ss2 Float64s)

Transform will return a new slice where each element has been transformed. The number of element returned will always be the same as the input.

Be careful when using this with slices of pointers. If you modify the input value it will affect the original slice. Be sure to return a new allocated object or deep copy the existing one.

func (Float64s) Unique

func (ss Float64s) Unique() Float64s

Unique returns a new slice with all of the unique values.

The items will be returned in a randomized order, even with the same input.

The number of items returned may be the same as the input or less. It will never return zero items unless then input slice has zero items.

A slice with zero elements is considered to be unique.

See AreUnique().

func (Float64s) Unselect

func (ss Float64s) Unselect(condition func(float64) bool) (ss2 Float64s)

Unselect works the same as Select, with a negated condition. That is, it will return a new slice only containing the elements that returned false from the condition. The returned slice may contain zero elements (nil).

type Ints

type Ints []int

func (Ints) All added in v1.4.0

func (ss Ints) All(fn func(value int) bool) bool

All will return true if all callbacks return true. It follows the same logic as the all() function in Python.

If the list is empty then true is always returned.

func (Ints) Any added in v1.4.0

func (ss Ints) Any(fn func(value int) bool) bool

Any will return true if any callbacks return true. It follows the same logic as the any() function in Python.

If the list is empty then false is always returned.

func (Ints) Append added in v1.3.0

func (ss Ints) Append(elements ...int) Ints

Append will return a new slice with the elements appended to the end. It is a wrapper for the internal append(). It is offered as a function so that it can more easily chained.

It is acceptable to provide zero arguments.

func (Ints) AreSorted

func (ss Ints) AreSorted() bool

AreSorted will return true if the slice is already sorted. It is a wrapper for sort.IntsAreSorted.

func (Ints) AreUnique

func (ss Ints) AreUnique() bool

AreUnique will return true if the slice contains elements that are all different (unique) from each other.

func (Ints) Average

func (ss Ints) Average() float64

Average is the average of all of the elements, or zero if there are no elements.

func (Ints) Contains

func (ss Ints) Contains(lookingFor int) bool

Contains returns true if the element exists in the slice.

When using slices of pointers it will only compare by address, not value.

func (Ints) Extend added in v1.3.0

func (ss Ints) Extend(slices ...Ints) (ss2 Ints)

Extend will return a new slice with the slices of elements appended to the end.

It is acceptable to provide zero arguments.

func (Ints) First

func (ss Ints) First() int

First returns the first element, or zero. Also see FirstOr().

func (Ints) FirstOr

func (ss Ints) FirstOr(defaultValue int) int

FirstOr returns the first element or a default value if there are no elements.

func (Ints) JSONString

func (ss Ints) JSONString() string

JSONString returns the JSON encoded array as a string.

One important thing to note is that it will treat a nil slice as an empty slice to ensure that the JSON value return is always an array.

func (Ints) Last

func (ss Ints) Last() int

Last returns the last element, or zero. Also see LastOr().

func (Ints) LastOr

func (ss Ints) LastOr(defaultValue int) int

LastOr returns the last element or a default value if there are no elements.

func (Ints) Len

func (ss Ints) Len() int

Len returns the number of elements.

func (Ints) Max

func (ss Ints) Max() (max int)

Max is the maximum value, or zero.

func (Ints) Min

func (ss Ints) Min() (min int)

Min is the minimum value, or zero.

func (Ints) Reverse

func (ss Ints) Reverse() Ints

Reverse returns a new copy of the slice with the elements ordered in reverse. This is useful when combined with Sort to get a descending sort order:

ss.Sort().Reverse()

func (Ints) Select

func (ss Ints) Select(condition func(int) bool) (ss2 Ints)

Select will return a new slice containing only the elements that return true from the condition. The returned slice may contain zero elements (nil).

Unselect works in the opposite way as Select.

func (Ints) Shuffle added in v1.6.0

func (ss Ints) Shuffle(source rand.Source) Ints

Shuffle returns shuffled slice by your rand.Source

func (Ints) Sort

func (ss Ints) Sort() Ints

Sort works similar to sort.Ints(). However, unlike sort.Ints the slice returned will be reallocated as to not modify the input slice.

See Reverse() and AreSorted().

func (Ints) Sum

func (ss Ints) Sum() (sum int)

Sum is the sum of all of the elements.

func (Ints) ToStrings added in v1.1.0

func (ss Ints) ToStrings(transform func(int) string) Strings

ToStrings transforms each element to a string.

func (Ints) Transform

func (ss Ints) Transform(fn func(int) int) (ss2 Ints)

Transform will return a new slice where each element has been transformed. The number of element returned will always be the same as the input.

Be careful when using this with slices of pointers. If you modify the input value it will affect the original slice. Be sure to return a new allocated object or deep copy the existing one.

func (Ints) Unique

func (ss Ints) Unique() Ints

Unique returns a new slice with all of the unique values.

The items will be returned in a randomized order, even with the same input.

The number of items returned may be the same as the input or less. It will never return zero items unless then input slice has zero items.

A slice with zero elements is considered to be unique.

See AreUnique().

func (Ints) Unselect

func (ss Ints) Unselect(condition func(int) bool) (ss2 Ints)

Unselect works the same as Select, with a negated condition. That is, it will return a new slice only containing the elements that returned false from the condition. The returned slice may contain zero elements (nil).

type Strings

type Strings []string

func (Strings) All added in v1.4.0

func (ss Strings) All(fn func(value string) bool) bool

All will return true if all callbacks return true. It follows the same logic as the all() function in Python.

If the list is empty then true is always returned.

func (Strings) Any added in v1.4.0

func (ss Strings) Any(fn func(value string) bool) bool

Any will return true if any callbacks return true. It follows the same logic as the any() function in Python.

If the list is empty then false is always returned.

func (Strings) Append added in v1.3.0

func (ss Strings) Append(elements ...string) Strings

Append will return a new slice with the elements appended to the end. It is a wrapper for the internal append(). It is offered as a function so that it can more easily chained.

It is acceptable to provide zero arguments.

func (Strings) AreSorted

func (ss Strings) AreSorted() bool

AreSorted will return true if the slice is already sorted. It is a wrapper for sort.StringsAreSorted.

func (Strings) AreUnique

func (ss Strings) AreUnique() bool

AreUnique will return true if the slice contains elements that are all different (unique) from each other.

func (Strings) Contains

func (ss Strings) Contains(lookingFor string) bool

Contains returns true if the element exists in the slice.

When using slices of pointers it will only compare by address, not value.

func (Strings) Extend added in v1.3.0

func (ss Strings) Extend(slices ...Strings) (ss2 Strings)

Extend will return a new slice with the slices of elements appended to the end.

It is acceptable to provide zero arguments.

func (Strings) First

func (ss Strings) First() string

First returns the first element, or zero. Also see FirstOr().

func (Strings) FirstOr

func (ss Strings) FirstOr(defaultValue string) string

FirstOr returns the first element or a default value if there are no elements.

func (Strings) JSONString

func (ss Strings) JSONString() string

JSONString returns the JSON encoded array as a string.

One important thing to note is that it will treat a nil slice as an empty slice to ensure that the JSON value return is always an array.

func (Strings) Join added in v1.2.0

func (ss Strings) Join(glue string) (s string)

Join returns a string from joining each of the elements.

func (Strings) Last

func (ss Strings) Last() string

Last returns the last element, or zero. Also see LastOr().

func (Strings) LastOr

func (ss Strings) LastOr(defaultValue string) string

LastOr returns the last element or a default value if there are no elements.

func (Strings) Len

func (ss Strings) Len() int

Len returns the number of elements.

func (Strings) Max

func (ss Strings) Max() (max string)

Max is the maximum value, or zero.

func (Strings) Min

func (ss Strings) Min() (min string)

Min is the minimum value, or zero.

func (Strings) Reverse

func (ss Strings) Reverse() Strings

Reverse returns a new copy of the slice with the elements ordered in reverse. This is useful when combined with Sort to get a descending sort order:

ss.Sort().Reverse()

func (Strings) Select

func (ss Strings) Select(condition func(string) bool) (ss2 Strings)

Select will return a new slice containing only the elements that return true from the condition. The returned slice may contain zero elements (nil).

Unselect works in the opposite way as Select.

func (Strings) Shuffle added in v1.6.0

func (ss Strings) Shuffle(source rand.Source) Strings

Shuffle returns shuffled slice by your rand.Source

func (Strings) Sort

func (ss Strings) Sort() Strings

Sort works similar to sort.Strings(). However, unlike sort.Strings the slice returned will be reallocated as to not modify the input slice.

See Reverse() and AreSorted().

func (Strings) ToStrings added in v1.1.0

func (ss Strings) ToStrings(transform func(string) string) Strings

ToStrings transforms each element to a string.

func (Strings) Transform

func (ss Strings) Transform(fn func(string) string) (ss2 Strings)

Transform will return a new slice where each element has been transformed. The number of element returned will always be the same as the input.

Be careful when using this with slices of pointers. If you modify the input value it will affect the original slice. Be sure to return a new allocated object or deep copy the existing one.

func (Strings) Unique

func (ss Strings) Unique() Strings

Unique returns a new slice with all of the unique values.

The items will be returned in a randomized order, even with the same input.

The number of items returned may be the same as the input or less. It will never return zero items unless then input slice has zero items.

A slice with zero elements is considered to be unique.

See AreUnique().

func (Strings) Unselect

func (ss Strings) Unselect(condition func(string) bool) (ss2 Strings)

Unselect works the same as Select, with a negated condition. That is, it will return a new slice only containing the elements that returned false from the condition. The returned slice may contain zero elements (nil).

Jump to

Keyboard shortcuts

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