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§

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

Traits§

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

Functions§

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