binarysearch

package
v0.0.0-...-69d094b Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package binarysearch 提供简单的二分查找法实现

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SearchCeiling

func SearchCeiling[T constraints.Ordered](s []T, tgt T) int

SearchCeiling 搜索等于 tgt 的最左边的值

func SearchCeilingByFunc

func SearchCeilingByFunc[T any](s []T, tgt T, compareFunc CompareFunction[T]) int

SearchCeilingByFunc 搜索等于 tgt 的最左边的值

func SearchFloor

func SearchFloor[T constraints.Ordered](s []T, tgt T) int

SearchFloor 搜索等于 tgt 的最左边的值

func SearchFloorByFunc

func SearchFloorByFunc[T any](s []T, tgt T, compareFunc CompareFunction[T]) int

SearchFloorByFunc 搜索等于 tgt 的最左边的值

func SearchOne

func SearchOne[T constraints.Ordered](s []T, tgt T) int

SearchOne 搜索一个可比较的切片

func SearchOneByFunc

func SearchOneByFunc[T any](s []T, tgt T, compareFunc CompareFunction[T]) int

SearchOneByFunc 使用比较函数进行大小判断来搜索一个值, 不论是一系列的左值还是右值

Types

type CompareFunction

type CompareFunction[T any] func(a, b T) int

CompareFunction 表示比较函数

Jump to

Keyboard shortcuts

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