unique

package module
v0.0.0-...-88950e5 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2018 License: Apache-2.0 Imports: 2 Imported by: 17

README

GoDoc Build Status

unique

Package unique provides primitives for sorting slices removing repeated elements.

a quick example

Executing this code:

	s := []int{3, 5, 1, 7, 2, 3, 7, 5, 2}
	less := func(i, j int) bool { return s[i] < s[j] }
	unique.Slice(&s, less)
	fmt.Println(s)

Will output the following:

[1 2 3 5 7]

Documentation

Overview

Package unique provides primitives for sorting slices removing repeated elements.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Slice

func Slice(slicePtr interface{}, less func(i, j int) bool)

Slice sorts the slice pointed by the provided pointer given the provided less function and removes repeated elements. The function panics if the provided interface is not a pointer to a slice.

Example
package main

import (
	"fmt"

	"github.com/campoy/unique"
)

func main() {
	s := []int{3, 5, 1, 7, 2, 3, 7, 5, 2}
	less := func(i, j int) bool { return s[i] < s[j] }
	unique.Slice(&s, less)
	fmt.Println(s)
}
Output:

[1 2 3 5 7]

Types

This section is empty.

Jump to

Keyboard shortcuts

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