swort

package module
v0.0.0-...-65c3dc0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 2 Imported by: 0

README

swort

A wrapper library for the sort package that is easy to use and supports generics and immutability.

Author

moznion (moznion@mail.moznion.net)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Slice

type Slice[IT any, ST cmp.Ordered] struct {
	// contains filtered or unexported fields
}

func MakeSlice

func MakeSlice[IT any, ST cmp.Ordered](items []IT, sortValueExtractor func(item IT) ST) *Slice[IT, ST]

func (*Slice[IT, ST]) Len

func (s *Slice[IT, ST]) Len() int

func (*Slice[IT, ST]) SearchFromOriginal

func (s *Slice[IT, ST]) SearchFromOriginal(item IT) (int, bool)

func (*Slice[IT, ST]) SortByAsc

func (s *Slice[IT, ST]) SortByAsc() *Sorted[IT, ST]

func (*Slice[IT, ST]) SortByDesc

func (s *Slice[IT, ST]) SortByDesc() *Sorted[IT, ST]

type Sorted

type Sorted[IT any, ST cmp.Ordered] struct {
	Items []IT
	// contains filtered or unexported fields
}

func (*Sorted[IT, ST]) Search

func (sd *Sorted[IT, ST]) Search(item IT) (int, bool)

Jump to

Keyboard shortcuts

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