@@ -1342,6 +1342,12 @@ impl<T, A: Allocator> VecDeque<T, A> {
13421342 /// Returns `true` if the deque contains an element equal to the
13431343 /// given value.
13441344 ///
1345+ /// This operation is *O*(*n*).
1346+ ///
1347+ /// Note that if you have a sorted `VecDeque`, [`binary_search`] may be faster.
1348+ ///
1349+ /// [`binary_search`]: VecDeque::binary_search
1350+ ///
13451351 /// # Examples
13461352 ///
13471353 /// ```
@@ -2560,7 +2566,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
25602566 }
25612567 }
25622568
2563- /// Binary searches the sorted deque for a given element.
2569+ /// Binary searches this `VecDeque` for a given element.
2570+ /// This behaves similarly to [`contains`] if this `VecDeque` is sorted.
25642571 ///
25652572 /// If the value is found then [`Result::Ok`] is returned, containing the
25662573 /// index of the matching element. If there are multiple matches, then any
@@ -2570,6 +2577,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
25702577 ///
25712578 /// See also [`binary_search_by`], [`binary_search_by_key`], and [`partition_point`].
25722579 ///
2580+ /// [`contains`]: VecDeque::contains
25732581 /// [`binary_search_by`]: VecDeque::binary_search_by
25742582 /// [`binary_search_by_key`]: VecDeque::binary_search_by_key
25752583 /// [`partition_point`]: VecDeque::partition_point
@@ -2614,7 +2622,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
26142622 self . binary_search_by ( |e| e. cmp ( x) )
26152623 }
26162624
2617- /// Binary searches the sorted deque with a comparator function.
2625+ /// Binary searches this `VecDeque` with a comparator function.
2626+ /// This behaves similarly to [`contains`] if this `VecDeque` is sorted.
26182627 ///
26192628 /// The comparator function should implement an order consistent
26202629 /// with the sort order of the deque, returning an order code that
@@ -2629,6 +2638,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
26292638 ///
26302639 /// See also [`binary_search`], [`binary_search_by_key`], and [`partition_point`].
26312640 ///
2641+ /// [`contains`]: VecDeque::contains
26322642 /// [`binary_search`]: VecDeque::binary_search
26332643 /// [`binary_search_by_key`]: VecDeque::binary_search_by_key
26342644 /// [`partition_point`]: VecDeque::partition_point
@@ -2667,7 +2677,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
26672677 }
26682678 }
26692679
2670- /// Binary searches the sorted deque with a key extraction function.
2680+ /// Binary searches this `VecDeque` with a key extraction function.
2681+ /// This behaves similarly to [`contains`] if this `VecDeque` is sorted.
26712682 ///
26722683 /// Assumes that the deque is sorted by the key, for instance with
26732684 /// [`make_contiguous().sort_by_key()`] using the same key extraction function.
@@ -2680,6 +2691,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
26802691 ///
26812692 /// See also [`binary_search`], [`binary_search_by`], and [`partition_point`].
26822693 ///
2694+ /// [`contains`]: VecDeque::contains
26832695 /// [`make_contiguous().sort_by_key()`]: VecDeque::make_contiguous
26842696 /// [`binary_search`]: VecDeque::binary_search
26852697 /// [`binary_search_by`]: VecDeque::binary_search_by
0 commit comments