New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/leiysky/selection

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/leiysky/selection

  • v0.0.0-20200914165550-e065bad5df5b
  • Source
  • Go
  • Socket score

Version published
Created
Source

Selection

Golang implementation of Introselect(Introspective Selection), which can get the k-th smallest value of a slice.

Usage

Download package with go get github.com/leiysky/selection, and make sure your Golang version is >=1.9.

Example:

import "github.com/leiysky/selection"
import "fmt"

type SortBy []int

func (a SortBy) Len() { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

func main() {
  data := SortBy{3, 2, 1, 4, 4}
  result := selection.Select(data, 1) // data[result] = 1
  result = selection.Select(data, 4) // data[result] = 4
  result = selection.Select(data, 5) // data[result] = 4
}

Contact

Email: leiysky@outlook.com

If you have any question, please open an issue.

FAQs

Package last updated on 14 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc