Crate slice_search

Source
Expand description

A collection of algorithms for searching within slices.

This module provides different search strategies and utilities to work with sorted slices. Currently, it supports binary and linear search algorithms, as well as an optimal search algorithm which picks between binary and linear searches depending on the size of the slice.

Structs§

BinarySearch
Performs a binary search on a slice, with computational complexity O(log n) However, for small searches, a linear search may be faster.
LinearSearch
Performs a simple linear search on a slice, with computational complexity O(n)
OptimalSearch
Chooses between binary and linear search depending on the size of the slice to search

Traits§

Search
An algorithm for searching a sorted slice, e.g. Binary or Linear

Functions§

lower_bound
Returns the index of the largest element less than or equal to the search key.
lower_bound_always
Returns the index of the biggest element less than or equal to the search key, or the first index.
upper_bound
Returns the index of the smallest element greater than or equal to the search key.
upper_bound_always
Returns the index of the smallest element greater than or equal to the search key, or the last index.