about summary refs log tree commit diff
path: root/library/alloc/src/vec/mod.rs
diff options
context:
space:
mode:
authorJacob Asper <jacobasper191@gmail.com>2024-02-18 05:14:17 -0500
committerJacob Asper <jacobasper191@gmail.com>2024-02-18 05:21:33 -0500
commitd2f825f26127f71cd853c602818452c8be876ea8 (patch)
treee9dedff396e9b963fe471311d1e8ed51acc6967c /library/alloc/src/vec/mod.rs
parent0a5d6841e8b14b2a4430ed675d2621fdd6747d04 (diff)
downloadrust-d2f825f26127f71cd853c602818452c8be876ea8.tar.gz
rust-d2f825f26127f71cd853c602818452c8be876ea8.zip
time complexity for insert
Diffstat (limited to 'library/alloc/src/vec/mod.rs')
-rw-r--r--library/alloc/src/vec/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index 27efffb72ac..711b4a8a8ef 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -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) {