time complexity for insert

This commit is contained in:
Jacob Asper 2024-02-18 05:14:17 -05:00
parent 0a5d6841e8
commit d2f825f261

View File

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