Giter Site home page Giter Site logo

uslice's Introduction

uslice

Go programming helpers for common 'pseudo-generic' typed-slice needs.

Usage

func BoolAppendUnique

func BoolAppendUnique(ref *[]bool, v bool)

Appends v to *ref only if *ref does not already contain v.

func BoolAppendUniques

func BoolAppendUniques(ref *[]bool, vals ...bool)

Appends each value in vals to *ref only *ref does not already contain it.

func BoolAt

func BoolAt(slice []bool, val bool) int

Returns the position of val in slice.

func BoolConvert

func BoolConvert(src []interface{}, sparse bool) (dst []bool)

Converts src to dst.

If sparse is true, then only successfully converted bool values are placed in dst, so there may not be a 1-to-1 correspondence of dst to src in length or indices.

If sparse is false, dst has the same length as src and non-convertable values remain zeroed.

func BoolEach

func BoolEach(sl []bool, apply ...func(bool) bool) []bool

Sets each bool in sl to the result of passing it to each apply func. Although sl is modified in-place, it is also returned for convenience.

func BoolEnsureCap

func BoolEnsureCap(ref *[]bool, capacity int)

Calls BoolSetCap only if the current cap(*ref) is less than the specified capacity.

func BoolEnsureLen

func BoolEnsureLen(ref *[]bool, length int)

Calls BoolSetLen only if the current len(*ref) is less than the specified length.

func BoolEquivalent

func BoolEquivalent(one, two []bool) bool

Returns whether one and two only contain identical values, regardless of ordering.

func BoolHas

func BoolHas(slice []bool, val bool) bool

Returns whether val is in slice.

func BoolHasAny

func BoolHasAny(slice []bool, vals ...bool) bool

Returns whether at least one of the specified vals is contained in slice.

func BoolRemove

func BoolRemove(ref *[]bool, v bool, all bool)

Removes the first occurrence of v encountered in *ref, or all occurrences if all is true.

func BoolSetCap

func BoolSetCap(ref *[]bool, capacity int)

Sets *ref to a copy of *ref with the specified capacity.

func BoolSetLen

func BoolSetLen(ref *[]bool, length int)

Sets *ref to a copy of *ref with the specified length.

func BoolWithout

func BoolWithout(slice []bool, keepOrder bool, withoutVals ...bool) []bool

Removes all specified withoutVals from slice.

func F64AppendUnique

func F64AppendUnique(ref *[]float64, v float64)

Appends v to *ref only if *ref does not already contain v.

func F64AppendUniques

func F64AppendUniques(ref *[]float64, vals ...float64)

Appends each value in vals to *ref only *ref does not already contain it.

func F64At

func F64At(slice []float64, val float64) int

Returns the position of val in slice.

func F64Convert

func F64Convert(src []interface{}, sparse bool) (dst []float64)

Converts src to dst.

If sparse is true, then only successfully converted float64 values are placed in dst, so there may not be a 1-to-1 correspondence of dst to src in length or indices.

If sparse is false, dst has the same length as src and non-convertable values remain zeroed.

func F64Each

func F64Each(sl []float64, apply ...func(float64) float64) []float64

Sets each float64 in sl to the result of passing it to each apply func. Although sl is modified in-place, it is also returned for convenience.

func F64EnsureCap

func F64EnsureCap(ref *[]float64, capacity int)

Calls F64SetCap only if the current cap(*ref) is less than the specified capacity.

func F64EnsureLen

func F64EnsureLen(ref *[]float64, length int)

Calls F64SetLen only if the current len(*ref) is less than the specified length.

func F64Equivalent

func F64Equivalent(one, two []float64) bool

Returns whether one and two only contain identical values, regardless of ordering.

func F64Has

func F64Has(slice []float64, val float64) bool

Returns whether val is in slice.

func F64HasAny

func F64HasAny(slice []float64, vals ...float64) bool

Returns whether at least one of the specified vals is contained in slice.

func F64Remove

func F64Remove(ref *[]float64, v float64, all bool)

Removes the first occurrence of v encountered in *ref, or all occurrences if all is true.

func F64SetCap

func F64SetCap(ref *[]float64, capacity int)

Sets *ref to a copy of *ref with the specified capacity.

func F64SetLen

func F64SetLen(ref *[]float64, length int)

Sets *ref to a copy of *ref with the specified length.

func F64Without

func F64Without(slice []float64, keepOrder bool, withoutVals ...float64) []float64

Removes all specified withoutVals from slice.

func IntAppendUnique

func IntAppendUnique(ref *[]int, v int)

Appends v to *ref only if *ref does not already contain v.

func IntAppendUniques

func IntAppendUniques(ref *[]int, vals ...int)

Appends each value in vals to *ref only *ref does not already contain it.

func IntAt

func IntAt(slice []int, val int) int

Returns the position of val in slice.

func IntConvert

func IntConvert(src []interface{}, sparse bool) (dst []int)

Converts src to dst.

If sparse is true, then only successfully converted int values are placed in dst, so there may not be a 1-to-1 correspondence of dst to src in length or indices.

If sparse is false, dst has the same length as src and non-convertable values remain zeroed.

func IntEach

func IntEach(sl []int, apply ...func(int) int) []int

Sets each int in sl to the result of passing it to each apply func. Although sl is modified in-place, it is also returned for convenience.

func IntEnsureCap

func IntEnsureCap(ref *[]int, capacity int)

Calls IntSetCap only if the current cap(*ref) is less than the specified capacity.

func IntEnsureLen

func IntEnsureLen(ref *[]int, length int)

Calls IntSetLen only if the current len(*ref) is less than the specified length.

func IntEquivalent

func IntEquivalent(one, two []int) bool

Returns whether one and two only contain identical values, regardless of ordering.

func IntHas

func IntHas(slice []int, val int) bool

Returns whether val is in slice.

func IntHasAny

func IntHasAny(slice []int, vals ...int) bool

Returns whether at least one of the specified vals is contained in slice.

func IntRemove

func IntRemove(ref *[]int, v int, all bool)

Removes the first occurrence of v encountered in *ref, or all occurrences if all is true.

func IntSetCap

func IntSetCap(ref *[]int, capacity int)

Sets *ref to a copy of *ref with the specified capacity.

func IntSetLen

func IntSetLen(ref *[]int, length int)

Sets *ref to a copy of *ref with the specified length.

func IntWithout

func IntWithout(slice []int, keepOrder bool, withoutVals ...int) []int

Removes all specified withoutVals from slice.

func StrAppendUnique

func StrAppendUnique(ref *[]string, v string)

Appends v to *ref only if *ref does not already contain v.

func StrAppendUniques

func StrAppendUniques(ref *[]string, vals ...string)

Appends each value in vals to *ref only *ref does not already contain it.

func StrAt

func StrAt(slice []string, val string) int

Returns the position of val in slice.

func StrAtIgnoreCase

func StrAtIgnoreCase(vals []string, val string) int

Returns the position of lower-case val in lower-case vals.

func StrConvert

func StrConvert(src []interface{}, sparse bool) (dst []string)

Converts src to dst.

If sparse is true, then only successfully converted string values are placed in dst, so there may not be a 1-to-1 correspondence of dst to src in length or indices.

If sparse is false, dst has the same length as src and non-convertable values remain zeroed.

func StrEach

func StrEach(sl []string, apply ...func(string) string) []string

Sets each string in sl to the result of passing it to each apply func. Although sl is modified in-place, it is also returned for convenience.

func StrEnsureCap

func StrEnsureCap(ref *[]string, capacity int)

Calls StrSetCap only if the current cap(*ref) is less than the specified capacity.

func StrEnsureLen

func StrEnsureLen(ref *[]string, length int)

Calls StrSetLen only if the current len(*ref) is less than the specified length.

func StrEquivalent

func StrEquivalent(one, two []string) bool

Returns whether one and two only contain identical values, regardless of ordering.

func StrHas

func StrHas(slice []string, val string) bool

Returns whether val is in slice.

func StrHasAny

func StrHasAny(slice []string, vals ...string) bool

Returns whether at least one of the specified vals is contained in slice.

func StrHasIgnoreCase

func StrHasIgnoreCase(vals []string, val string) bool

Returns whether lower-case val is in lower-case vals.

func StrRemove

func StrRemove(ref *[]string, v string, all bool)

Removes the first occurrence of v encountered in *ref, or all occurrences if all is true.

func StrSetCap

func StrSetCap(ref *[]string, capacity int)

Sets *ref to a copy of *ref with the specified capacity.

func StrSetLen

func StrSetLen(ref *[]string, length int)

Sets *ref to a copy of *ref with the specified length.

func StrWithout

func StrWithout(slice []string, keepOrder bool, withoutVals ...string) []string

Removes all specified withoutVals from slice.

uslice's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.