# BinarySearchExtension

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/struct-binarysearchextension/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct BinarySearchExtension
```

Binary searching of a list with a comparer.

Unlike `slice::binary_search_by`, which may return any of several equal
items, the search visits the items in a fixed order. The result is the
index of the found item or the bitwise complement of the index of the
next larger item.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/binary_search_extension.rs#L25)

## Members

- [`binary_search`](#function-binary_search)
- [`binary_search_range`](#function-binary_search_range)

<a id="function-binary_search"></a>

### binary_search

```rust
fn binary_search<T>(list: &[T], value: &T, comparer: impl Fn(&T, &T) -> Ordering) -> i32
```

Performs a binary search on the entire contents of a list.

Returns the index of the found item; otherwise the bitwise complement
of the index of the next larger item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/binary_search_extension.rs#L38)

<a id="function-binary_search_range"></a>

### binary_search_range

```rust
fn binary_search_range<T>(list: &[T], index: i32, length: i32, value: &T, comparer: impl Fn(&T, &T) -> Ordering) -> i32
```

Performs a binary search on a subset of a list: `length` items
starting at `index`.

Returns the index of the found item; otherwise the bitwise complement
of the index of the next larger item.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/binary_search_extension.rs#L47)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
