pub struct CircularQueue<T> { /* fields omitted */ }A circular buffer-like queue.
Constructs a new, empty CircularQueue<T> with the requested capacity.
Panics if the requested capacity is 0.
extern crate libtectonic;
use libtectonic::client::circular_queue::CircularQueue;
let mut queue: CircularQueue<i32> = CircularQueue::with_capacity(5);
Returns the current number of elements in the queue.
extern crate libtectonic;
use libtectonic::client::circular_queue::CircularQueue;
let mut queue = CircularQueue::with_capacity(5);
queue.push(1);
queue.push(2);
queue.push(3);
assert_eq!(queue.len(), 3);
Returns true if the queue contains no elements.
extern crate libtectonic;
use libtectonic::client::circular_queue::CircularQueue;
let mut queue = CircularQueue::with_capacity(5);
assert!(queue.is_empty());
queue.push(1);
assert!(!queue.is_empty());
Returns the capacity of the queue.
extern crate libtectonic;
use libtectonic::client::circular_queue::CircularQueue;
let queue: CircularQueue<i32> = CircularQueue::with_capacity(5);
assert_eq!(queue.capacity(), 5);
Clears the queue.
extern crate libtectonic;
use libtectonic::client::circular_queue::CircularQueue;
let mut queue = CircularQueue::with_capacity(5);
queue.push(1);
queue.push(2);
queue.push(3);
queue.clear();
assert_eq!(queue.len(), 0);
Pushes a new element into the queue.
Once the capacity is reached, pushing new items will overwrite old ones.
extern crate libtectonic;
use libtectonic::client::circular_queue::CircularQueue;
let mut queue = CircularQueue::with_capacity(3);
queue.push(1);
queue.push(2);
queue.push(3);
queue.push(4);
assert_eq!(queue.len(), 3);
let mut iter = queue.iter();
assert_eq!(iter.next(), Some(&4));
assert_eq!(iter.next(), Some(&3));
assert_eq!(iter.next(), Some(&2));
Pops the elements from the queue(LIFO).
Pops at max self.capacity number of items.
extern crate libtectonic;
use libtectonic::client::circular_queue::CircularQueue;
let mut queue = CircularQueue::with_capacity(3);
queue.push(1);
queue.push(2);
queue.push(3);
queue.push(4);
assert_eq!(queue.len(), 3);
assert_eq!(queue.pop(), Some(4));
assert_eq!(queue.pop(), Some(3));
assert_eq!(queue.pop(), Some(2));
assert_eq!(queue.pop(), None);
Returns an iterator over the queue's contents.
The iterator goes from the most recently pushed items to the oldest ones.
extern crate libtectonic;
use libtectonic::client::circular_queue::CircularQueue;
let mut queue = CircularQueue::with_capacity(3);
queue.push(1);
queue.push(2);
queue.push(3);
queue.push(4);
let mut iter = queue.iter();
assert_eq!(iter.next(), Some(&4));
assert_eq!(iter.next(), Some(&3));
assert_eq!(iter.next(), Some(&2));
Returns a mutable iterator over the queue's contents.
The iterator goes from the most recently pushed items to the oldest ones.
extern crate libtectonic;
use libtectonic::client::circular_queue::CircularQueue;
let mut queue = CircularQueue::with_capacity(3);
queue.push(1);
queue.push(2);
queue.push(3);
queue.push(4);
let mut iter = queue.iter_mut();
assert_eq!(iter.next(), Some(&mut 4));
assert_eq!(iter.next(), Some(&mut 3));
assert_eq!(iter.next(), Some(&mut 2));
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static