slice

package module
v0.0.0-...-90b64e0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

package slice

package slice

package set

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distinct

func Distinct(v interface{}, key func(i int) interface{})

Distinct distinct elem in array

func NewIntegerSet

func NewIntegerSet(s Integer) integerSet

Types

type Integer

type Integer []int

func (Integer) Contains

func (s Integer) Contains(x int) bool

Contains check if slice contains elem

func (Integer) Distinct

func (s Integer) Distinct() Integer

Distinct distinct elem in slice only keep different elem in slice it will keep order of origin WARNING: this method will change origin slice sort and return it

Example:

Integer([]int{2,2,1,3}).Distinct()

>>> []int{2,1,3} origin slice: []int{2,1,3}

func (Integer) Filter

func (s Integer) Filter(fn func(x int) bool) Integer

Filter filter elem in slice if fn(x) is true, it will keep it. Example:

Integer([]int{1,2,3,4}).Filter(func(x int) bool {return x%2==0})

>>> []int{2,4}

func (Integer) Sort

func (s Integer) Sort() Integer

Sort sort integer slice it depends on sort.Sort

Jump to

Keyboard shortcuts

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