Struct sdset::set::SetBuf [−][src]
pub struct SetBuf<T>(_);
An owned, set (akin to String
).
Methods
impl<T> SetBuf<T>
[src]
impl<T> SetBuf<T>
pub fn new(vec: Vec<T>) -> Result<Self, Error> where
T: Ord,
[src]
pub fn new(vec: Vec<T>) -> Result<Self, Error> where
T: Ord,
Construct a SetBuf
only if it is sorted and deduplicated.
use sdset::SetBuf; let vec = vec![1, 2, 4, 6, 7]; let setbuf = SetBuf::new(vec)?; // this vec is not sorted! let vec = vec![1, 2, 4, 7, 6]; let setbuf = SetBuf::new(vec); assert_eq!(setbuf, Err(Error::NotSort));
pub fn new_unchecked(vec: Vec<T>) -> Self
[src]
pub fn new_unchecked(vec: Vec<T>) -> Self
Construct a SetBuf
without checking it.
use sdset::SetBuf; // this vec is not sorted let vec = vec![1, 2, 4, 7, 6]; // but we can still create a SetBuf, so be carreful! let setbuf = SetBuf::new_unchecked(vec);
pub fn as_set(&self) -> &Set<T>
[src]
pub fn as_set(&self) -> &Set<T>
Return the Set
owned by this SetBuf
.
use sdset::{Set, SetBuf}; let vec = vec![1, 2, 4, 6, 7]; let setbuf = SetBuf::new(vec.clone())?; let set = Set::new(&vec)?; assert_eq!(setbuf.as_set(), set);
pub fn into_vec(self) -> Vec<T>
[src]
pub fn into_vec(self) -> Vec<T>
Methods from Deref<Target = Set<T>>
pub fn to_set_buf(&self) -> SetBuf<T> where
T: Clone,
[src]
pub fn to_set_buf(&self) -> SetBuf<T> where
T: Clone,
Construct the owning version of the Set
.
use sdset::{Set, SetBuf}; let set = Set::new(&[1, 2, 4, 6, 7])?; let setbuf: SetBuf<_> = set.to_set_buf();
pub fn as_slice(&self) -> &[T]
[src]
pub fn as_slice(&self) -> &[T]
Return the slice "inside" of this Set
.
use sdset::Set; let slice = &[1, 2, 4, 6, 7]; let set = Set::new(slice)?; assert_eq!(set.as_slice(), slice);
Trait Implementations
impl<T: Debug> Debug for SetBuf<T>
[src]
impl<T: Debug> Debug for SetBuf<T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Clone> Clone for SetBuf<T>
[src]
impl<T: Clone> Clone for SetBuf<T>
fn clone(&self) -> SetBuf<T>
[src]
fn clone(&self) -> SetBuf<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: PartialEq> PartialEq for SetBuf<T>
[src]
impl<T: PartialEq> PartialEq for SetBuf<T>
fn eq(&self, other: &SetBuf<T>) -> bool
[src]
fn eq(&self, other: &SetBuf<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &SetBuf<T>) -> bool
[src]
fn ne(&self, other: &SetBuf<T>) -> bool
This method tests for !=
.
impl<T: Eq> Eq for SetBuf<T>
[src]
impl<T: Eq> Eq for SetBuf<T>
impl<T: PartialOrd> PartialOrd for SetBuf<T>
[src]
impl<T: PartialOrd> PartialOrd for SetBuf<T>
fn partial_cmp(&self, other: &SetBuf<T>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &SetBuf<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &SetBuf<T>) -> bool
[src]
fn lt(&self, other: &SetBuf<T>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &SetBuf<T>) -> bool
[src]
fn le(&self, other: &SetBuf<T>) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &SetBuf<T>) -> bool
[src]
fn gt(&self, other: &SetBuf<T>) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &SetBuf<T>) -> bool
[src]
fn ge(&self, other: &SetBuf<T>) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: Ord> Ord for SetBuf<T>
[src]
impl<T: Ord> Ord for SetBuf<T>
fn cmp(&self, other: &SetBuf<T>) -> Ordering
[src]
fn cmp(&self, other: &SetBuf<T>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<T: Hash> Hash for SetBuf<T>
[src]
impl<T: Hash> Hash for SetBuf<T>
fn hash<__HT: Hasher>(&self, state: &mut __HT)
[src]
fn hash<__HT: Hasher>(&self, state: &mut __HT)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T> Deref for SetBuf<T>
[src]
impl<T> Deref for SetBuf<T>
type Target = Set<T>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
fn deref(&self) -> &Self::Target
Dereferences the value.
impl<T> AsRef<Set<T>> for SetBuf<T>
[src]
impl<T> AsRef<Set<T>> for SetBuf<T>
impl<T> AsRef<[T]> for SetBuf<T>
[src]
impl<T> AsRef<[T]> for SetBuf<T>