xslice

package
v0.25.15 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 4 Imported by: 13

README

GoKit - xslice

Slice kits for Golang development.

Installation

go get -u github.com/likexian/gokit

Importing

import (
    "github.com/likexian/gokit/xslice"
)

Documentation

Visit the docs on GoDoc

Example

Get unique of string array
array := xslice.Unique([]string{"a", "a", "b", "b", "b", "c"})
fmt.Println("new array:", array)
Get unique of int array
array := xslice.Unique([]int{0, 0, 1, 1, 1, 2, 2, 3})
fmt.Println("new array:", array)

License

Copyright 2012-2024 Li Kexian

Licensed under the Apache License 2.0

Donation

If this project is helpful, please share it with friends.

If you want to thank me, you can give me a cup of coffee.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Author

func Author() string

Author returns package author

func CheckIsFunc added in v0.21.7

func CheckIsFunc(fn interface{}, n ...int) error

CheckIsFunc check if fn is a function with n[0] arguments and n[1] returns

func Chunk added in v0.21.9

func Chunk(v interface{}, size int) interface{}

Chunk split slice into chunks

func Concat added in v0.21.9

func Concat(v interface{}) interface{}

Concat returns a new flatten slice of []slice

func Different added in v0.21.4

func Different(x, y interface{}) interface{}

Different returns values in x but not in y

func Fill added in v0.21.6

func Fill(v interface{}, count int) interface{}

Fill returns a slice with count number of v values

func Filter added in v0.21.7

func Filter(v interface{}, fn interface{}) interface{}

Filter filter slice values using callback function fn

func Index added in v0.23.2

func Index(v interface{}, value interface{}) int

Index returns the index of the first value in v, or -1 if not found

func Intersect added in v0.21.4

func Intersect(x, y interface{}) interface{}

Intersect returns values in both slices

func IsSlice added in v0.21.5

func IsSlice(v interface{}) bool

IsSlice returns whether value is slice

func IsUnique added in v0.21.3

func IsUnique(v interface{}) bool

IsUnique returns whether slice values is unique

func License

func License() string

License returns package license

func Map added in v0.21.8

func Map(v interface{}, fn interface{}) interface{}

Map apply callback function fn to elements of slice

func Merge added in v0.21.4

func Merge(x, y interface{}) interface{}

Merge append y values to x if not exists in

func Reduce added in v0.21.8

func Reduce(v interface{}, fn interface{}) interface{}

Reduce reduce the slice values using callback function fn

func Reverse added in v0.21.6

func Reverse(v interface{})

Reverse returns a slice with elements in reverse order

func Shuffle added in v0.21.9

func Shuffle(v interface{})

Shuffle shuffle a slice

func Unique

func Unique(v interface{}) interface{}

Unique returns unique values of slice

func Version

func Version() string

Version returns package version

Types

This section is empty.

Jump to

Keyboard shortcuts

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