|
97 | 97 | //! |
98 | 98 | //! ## Sequences |
99 | 99 | //! |
100 | | -//! | | get(i) | insert(i) | remove(i) | append | split_off(i) | |
101 | | -//! |----------------|----------------|-----------------|----------------|--------|----------------| |
102 | | -//! | [`Vec`] | O(1) | O(n-i)* | O(n-i) | O(m)* | O(n-i) | |
103 | | -//! | [`VecDeque`] | O(1) | O(min(i, n-i))* | O(min(i, n-i)) | O(m)* | O(min(i, n-i)) | |
104 | | -//! | [`LinkedList`] | O(min(i, n-i)) | O(min(i, n-i)) | O(min(i, n-i)) | O(1) | O(min(i, n-i)) | |
| 100 | +//! | | get(i) | insert(i) | remove(i) | append | split_off(i) | |
| 101 | +//! |----------------|------------------------|-------------------------|------------------------|-----------|------------------------| |
| 102 | +//! | [`Vec`] | *O*(1) | *O*(*n*-*i*)* | *O*(*n*-*i*) | *O*(*m*)* | *O*(*n*-*i*) | |
| 103 | +//! | [`VecDeque`] | *O*(1) | *O*(min(*i*, *n*-*i*))* | *O*(min(*i*, *n*-*i*)) | *O*(*m*)* | *O*(min(*i*, *n*-*i*)) | |
| 104 | +//! | [`LinkedList`] | *O*(min(*i*, *n*-*i*)) | *O*(min(*i*, *n*-*i*)) | *O*(min(*i*, *n*-*i*)) | *O*(1) | *O*(min(*i*, *n*-*i*)) | |
105 | 105 | //! |
106 | 106 | //! Note that where ties occur, [`Vec`] is generally going to be faster than [`VecDeque`], and |
107 | 107 | //! [`VecDeque`] is generally going to be faster than [`LinkedList`]. |
|
110 | 110 | //! |
111 | 111 | //! For Sets, all operations have the cost of the equivalent Map operation. |
112 | 112 | //! |
113 | | -//! | | get | insert | remove | range | append | |
114 | | -//! |--------------|-----------|-----------|-----------|-----------|--------| |
115 | | -//! | [`HashMap`] | O(1)~ | O(1)~* | O(1)~ | N/A | N/A | |
116 | | -//! | [`BTreeMap`] | O(log(n)) | O(log(n)) | O(log(n)) | O(log(n)) | O(n+m) | |
| 113 | +//! | | get | insert | remove | range | append | |
| 114 | +//! |--------------|---------------|---------------|---------------|---------------|--------------| |
| 115 | +//! | [`HashMap`] | *O*(1)~ | *O*(1)~* | *O*(1)~ | N/A | N/A | |
| 116 | +//! | [`BTreeMap`] | *O*(log(*n*)) | *O*(log(*n*)) | *O*(log(*n*)) | *O*(log(*n*)) | *O*(*n*+*m*) | |
117 | 117 | //! |
118 | 118 | //! # Correct and Efficient Usage of Collections |
119 | 119 | //! |
|
0 commit comments