pub struct VecLike<'a, T: 'a> { /* private fields */ }
Expand description
A vector like view of a set.
Implementations§
Source§impl<'a, T: 'a> VecLike<'a, T>
impl<'a, T: 'a> VecLike<'a, T>
Sourcepub fn get(&self, index: usize) -> Option<&'a T>
pub fn get(&self, index: usize) -> Option<&'a T>
Returns the element of the vector at the given index,
or None
if the index is out of bounds.
§Examples
use splay_tree::SplaySet;
let mut set = SplaySet::new();
set.insert("foo");
set.insert("bar");
set.insert("baz");
let vec = set.as_vec_like();
assert_eq!(vec.get(0), Some(&"foo"));
assert_eq!(vec.get(1), Some(&"bar"));
assert_eq!(vec.get(2), Some(&"baz"));
assert_eq!(vec.get(3), None);
Sourcepub fn first(&self) -> Option<&'a T>
pub fn first(&self) -> Option<&'a T>
Returns the first element of the vector, or None
if it is empty.
§Examples
use splay_tree::SplaySet;
let mut set = SplaySet::new();
set.insert("foo");
set.insert("bar");
set.insert("baz");
let vec = set.as_vec_like();
assert_eq!(vec.first(), Some(&"foo"));
Sourcepub fn last(&self) -> Option<&'a T>
pub fn last(&self) -> Option<&'a T>
Returns the last element of the vector, or None
if it is empty.
§Examples
use splay_tree::SplaySet;
let mut set = SplaySet::new();
set.insert("foo");
set.insert("bar");
set.insert("baz");
let vec = set.as_vec_like();
assert_eq!(vec.last(), Some(&"baz"));
Sourcepub fn iter(&self) -> VecLikeIter<'a, T> ⓘ
pub fn iter(&self) -> VecLikeIter<'a, T> ⓘ
Gets an iterator over the vector’s elements, in positional order (low to high).
§Examples
use splay_tree::SplaySet;
let mut set = SplaySet::new();
set.insert("foo");
set.insert("bar");
set.insert("baz");
assert_eq!(set.iter().cloned().collect::<Vec<_>>(), ["bar", "baz", "foo"]);
let vec = set.as_vec_like();
assert_eq!(vec.iter().cloned().collect::<Vec<_>>(), ["foo", "bar", "baz"]);
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for VecLike<'a, T>
impl<'a, T> RefUnwindSafe for VecLike<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for VecLike<'a, T>where
T: Sync,
impl<'a, T> Sync for VecLike<'a, T>where
T: Sync,
impl<'a, T> Unpin for VecLike<'a, T>
impl<'a, T> UnwindSafe for VecLike<'a, T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more