morecmp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: GPL-3.0 Imports: 1 Imported by: 3

Documentation

Overview

morecmp implements extensions to the standard cmp library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmpFunc

type CmpFunc[T any] func(T, T) int

CmpFunc is a convience that represents the comparison functions used by APIs like slices.SortFunc.

func Comparing

func Comparing[T any, E cmp.Ordered](f func(T) E) CmpFunc[T]

Comparing creates a CmpFunc that compares Ts by first converting them into Es.

func ComparingFunc

func ComparingFunc[T, E any](f func(T) E, g CmpFunc[E]) CmpFunc[T]

Comparing creates a CmpFunc that compares Ts by first converting them into Es, then then checking those Es with the provided CmpFunc.

func FalseFirst

func FalseFirst() CmpFunc[bool]

FalseFirst returns a CmpFunc[bool] that sorts false before true.

func TrueFirst

func TrueFirst() CmpFunc[bool]

TrueFirst returns a CmpFunc[bool] that sorts true before false.

func (CmpFunc[T]) AndThen

func (f CmpFunc[T]) AndThen(next ...CmpFunc[T]) CmpFunc[T]

AndThen returns a new CmpFunc that first checks this CmpFunc, and if the comparison is zero, checks the next CmpFuncs in order.

func (CmpFunc[T]) LessFunc

func (f CmpFunc[T]) LessFunc() LessFunc[T]

LessFunc converts this CmpFunc into a LessFunc.

func (CmpFunc[T]) Reversed added in v0.2.0

func (f CmpFunc[T]) Reversed() CmpFunc[T]

Reversed returns a new CmpFunc that orders the opposite of this one.

type LessFunc

type LessFunc[T any] func(T, T) bool

LessFunc is a convenience that repesents the comparison functions used by older APIs like sort.Slice.

Jump to

Keyboard shortcuts

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