Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Add complexity bound on binary search methods #239

Merged
merged 1 commit into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 1.16.1-dev

## 1.16.0

* Add an `Iterable.slices` extension method.
Expand Down
4 changes: 4 additions & 0 deletions lib/src/algorithms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ int binarySearchBy<E, K>(List<E> sortedList, K Function(E element) keyOf,
/// Returns the first position in [sortedList] that does not compare less than
/// [value].
///
/// Uses binary search to find the location of [value].
/// This takes on the order of `log(n)` comparisons.
/// If the list isn't sorted according to the [compare] function, the result
/// is unpredictable.
///
Expand All @@ -72,6 +74,8 @@ int lowerBound<E>(List<E> sortedList, E value, {int Function(E, E)? compare}) {

/// Returns the first position in [sortedList] that is not before [value].
///
/// Uses binary search to find the location of [value].
/// This takes on the order of `log(n)` comparisons.
/// Elements are compared using the [compare] function of the [keyOf] property of
/// the elements.
/// If the list isn't sorted according to this order, the result is unpredictable.
Expand Down
8 changes: 8 additions & 0 deletions lib/src/list_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extension ListExtensions<E> on List<E> {
/// Returns the index of [element] in this sorted list.
///
/// Uses binary search to find the location of [element].
/// This takes on the order of `log(n)` comparisons.
/// The list *must* be sorted according to [compare],
/// otherwise the result is unspecified
///
Expand All @@ -26,6 +27,7 @@ extension ListExtensions<E> on List<E> {
/// Returns the index of [element] in this sorted list.
///
/// Uses binary search to find the location of [element].
/// This takes on the order of `log(n)` comparisons.
/// The list *must* be sorted according to [compare] on the [keyOf] of elements,
/// otherwise the result is unspecified.
///
Expand All @@ -42,6 +44,7 @@ extension ListExtensions<E> on List<E> {
/// Returns the index of [element] in this sorted list.
///
/// Uses binary search to find the location of [element].
/// This takes on the order of `log(n)` comparisons.
/// The list *must* be sorted according to the natural ordering of
/// the [keyOf] of elements, otherwise the result is unspecified.
///
Expand All @@ -57,6 +60,7 @@ extension ListExtensions<E> on List<E> {
/// Returns the index where [element] should be in this sorted list.
///
/// Uses binary search to find the location of [element].
/// This takes on the order of `log(n)` comparisons.
/// The list *must* be sorted according to [compare],
/// otherwise the result is unspecified.
///
Expand All @@ -71,6 +75,7 @@ extension ListExtensions<E> on List<E> {
/// Returns the index where [element] should be in this sorted list.
///
/// Uses binary search to find the location of [element].
/// This takes on the order of `log(n)` comparisons.
/// The list *must* be sorted according to [compare] of
/// the [keyOf] of the elements, otherwise the result is unspecified.
///
Expand All @@ -90,6 +95,7 @@ extension ListExtensions<E> on List<E> {
/// Returns the index where [element] should be in this sorted list.
///
/// Uses binary search to find the location of [element].
/// This takes on the order of `log(n)` comparisons.
/// The list *must* be sorted according to the
/// natural ordering of the [keyOf] of the elements,
/// otherwise the result is unspecified.
Expand Down Expand Up @@ -276,6 +282,7 @@ extension ListComparableExtensions<E extends Comparable<E>> on List<E> {
/// Returns the index of [element] in this sorted list.
///
/// Uses binary search to find the location of [element].
/// This takes on the order of `log(n)` comparisons.
/// The list *must* be sorted according to [compare],
/// otherwise the result is unspecified.
/// If [compare] is omitted, it uses the natural order of the elements.
Expand All @@ -288,6 +295,7 @@ extension ListComparableExtensions<E extends Comparable<E>> on List<E> {
/// Returns the index where [element] should be in this sorted list.
///
/// Uses binary search to find the location of where [element] should be.
/// This takes on the order of `log(n)` comparisons.
/// The list *must* be sorted according to [compare],
/// otherwise the result is unspecified.
/// If [compare] is omitted, it uses the natural order of the elements.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: collection
version: 1.16.0
version: 1.16.1-dev

description: Collections and utilities functions and classes related to collections.
repository: https://github.com/dart-lang/collection
Expand Down