-
Rust❤️ VecDeque 벡터 맨 앞에 넣으려고 하면 VecDeque가 빠르다코딩Coding/Rust❤️Optimization❤️ 2022. 6. 14. 05:47728x90
use std::collections::VecDeque; fn main() { let mut a = VecDeque::from([1, 2, 3]); a.push_back(6); let doubled: VecDeque<i32> = a.iter().map(|&x| x * 2).collect(); println!("{doubled:?}"); }
결과
cargo run Compiling rust_polyglot v0.1.0 (/Users/globalyoung/Documents/Project/Github/rust_project/rust_polyglot) Finished dev [unoptimized + debuginfo] target(s) in 0.10s Running `target/debug/rust_polyglot` [2, 4, 6, 12]
출처 : https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html
VecDeque in std::collections - Rust
Tries to reserve capacity for at least additional more elements to be inserted in the given deque. The collection may reserve more space to avoid frequent reallocations. After calling try_reserve, capacity will be greater than or equal to self.len() + addi
doc.rust-lang.org
다른 출처 :
프로그래밍 언어 러스트를 배웁시다! 056 Easy Rust in Korean: VecDeque
반응형'코딩Coding > Rust❤️Optimization❤️' 카테고리의 다른 글
cargo bench 사용법❤️-Benchmark testing your Rust Code | Let's Get Rusty (0) 2022.06.15 Rust❤️rayon과 일반 기능{into_par_iter() vs into_iter()}❤️의 차이는 얼마나 날까?(concurrency의 대단함 (0) 2022.06.14 Cargo benchmark활용법 (0) 2022.06.14 Rust❤️]rayon 정의&Q&A 연습 및 관련 자료 (0) 2022.06.14 hyperfine 러스트 벤치마크 프로그램 benchmark (0) 2022.06.10 Rust❤️) tokio 최적화 (0) 2022.06.09 Rust❤️최적화] &str 으로 속도 더 빠르게 만들기String을 &str로 바꾸면 더 빨라진다 ㅎ_8분부터 (0) 2022.06.08 10 Design Patterns Explained in 10 Minutes- Fireship (0) 2022.06.01