Skip to content

Commit d2f825f

Browse files
committed
time complexity for insert
1 parent 0a5d684 commit d2f825f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

library/alloc/src/vec/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,12 @@ impl<T, A: Allocator> Vec<T, A> {
14901490
/// vec.insert(4, 5);
14911491
/// assert_eq!(vec, [1, 4, 2, 3, 5]);
14921492
/// ```
1493+
///
1494+
/// # Time complexity
1495+
///
1496+
/// Takes *O*(`len`) time. All items after the insertion index must be
1497+
/// shifted to the right. In the worst case, all elements are shifted when
1498+
/// the insertion index is 0.
14931499
#[cfg(not(no_global_oom_handling))]
14941500
#[stable(feature = "rust1", since = "1.0.0")]
14951501
pub fn insert(&mut self, index: usize, element: T) {

0 commit comments

Comments
 (0)