Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // This can mean that a list with 0 items was passed in. ErrSearchResultInvalid = errors.New("ErrSearchResultInvalid") )
Functions ¶
This section is empty.
Types ¶
type BinarySearchFunc ¶
type BinarySearchFunc[T numberType] func(i T) (SearchResult, error)
BinarySearchFunc is a caller-supplied function that tells the Binary Search function to go higher or lower
func CreateByteComparatorFunc ¶
func CreateByteComparatorFunc[T numberType](needle []byte, getListValueAtIndex func(index T) []byte) BinarySearchFunc[T]
CreateByteComparatorFunc creates a comparator function for keys of type []byte
type BinarySearchOptions ¶
type BinarySearchOptions struct {
MaxIterations int64
}
type BinarySearchResult ¶
type BinarySearchResult[T numberType] struct { LastIndexChecked T LastResult SearchResult }
func BinarySearch ¶
func BinarySearch[T numberType](listSize T, binarySearchFunc BinarySearchFunc[T], passedInOptions *BinarySearchOptions) (BinarySearchResult[T], error)
BinarySearch performs a binary search on a given list size and binary search function please note, the exact value you search for may not be found - please check the BinarySearchResult value
type SearchResult ¶
type SearchResult int
const ( SearchResultUnknown SearchResult = iota // SearchResultFound indicates the desired result has been found and the search should terminate SearchResultFound // SearchResultGoLower indicates the search should look lower SearchResultGoLower // SearchResultGoHigher indicates the search should look higher SearchResultGoHigher )
func (SearchResult) String ¶
func (i SearchResult) String() string
Click to show internal directories.
Click to hide internal directories.