[][src]Function tao_of_rust::ch02::collections::vec_deque

pub fn vec_deque()

线性序列:双端队列(VecDeque)

Basic usage:

use std::collections::VecDeque;
fn vec_deque() {
    let mut buf = VecDeque::new();

    buf.push_front(1);
    buf.push_front(2);
    assert_eq!(buf.get(0), Some(&2));
    assert_eq!(buf.get(1), Some(&1));

    buf.push_back(3);
    buf.push_back(4);
    buf.push_back(5);

    assert_eq!(buf.get(2), Some(&3));
    assert_eq!(buf.get(3), Some(&4));
    assert_eq!(buf.get(4), Some(&5));
}
vec_deque();Run