pub struct VecSet<T>(/* private fields */);Expand description
An set of items stored in order in a Vec.
This is always efficient for small sizes of sets, and efficient for large sizes when insertion is not needed (i.e. items are placed into the set in bulk).
Implementations§
Source§impl<T: Eq + PartialEq + Ord + PartialOrd> VecSet<T>
impl<T: Eq + PartialEq + Ord + PartialOrd> VecSet<T>
Sourcepub fn from_sorted(v: Vec<T>) -> Result<Self, ()>
pub fn from_sorted(v: Vec<T>) -> Result<Self, ()>
Sourcepub fn is_disjoint(&self, other: &Self) -> bool
pub fn is_disjoint(&self, other: &Self) -> bool
Compares the items in two sets.
Returns true iff every item in the set is not found in other.
Sourcepub fn to_vec(&self) -> Vec<T>where
T: Clone,
pub fn to_vec(&self) -> Vec<T>where
T: Clone,
Return a Vec of sorted items by cloning this set.
Sourcepub fn insert(&mut self, t: T) -> bool
pub fn insert(&mut self, t: T) -> bool
Insert item into the set.
Inserts some item t into the set.
Returns true iff the item was not already in the set.
Sourcepub fn extend(&mut self, iter: impl IntoIterator<Item = T>)
pub fn extend(&mut self, iter: impl IntoIterator<Item = T>)
Insert multiple items from an iterator.
Sourcepub fn contains(&self, t: &T) -> bool
pub fn contains(&self, t: &T) -> bool
Check if a value is in the set.
Returns true iff the set contains a value equal to t.
Trait Implementations§
Source§impl<T: Decode + Eq + PartialEq + Ord + PartialOrd> Decode for VecSet<T>
impl<T: Decode + Eq + PartialEq + Ord + PartialOrd> Decode for VecSet<T>
Source§fn decode<I: Input>(input: &mut I) -> Result<Self, DecodeError>
fn decode<I: Input>(input: &mut I) -> Result<Self, DecodeError>
Attempt to deserialise the value from input.
Source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl<T> Encode for VecSet<T>
impl<T> Encode for VecSet<T>
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
Source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
Convert self to a slice and append it to the destination.
Source§fn using_encoded<__CodecOutputReturn, __CodecUsingEncodedCallback: FnOnce(&[u8]) -> __CodecOutputReturn>(
&self,
f: __CodecUsingEncodedCallback,
) -> __CodecOutputReturn
fn using_encoded<__CodecOutputReturn, __CodecUsingEncodedCallback: FnOnce(&[u8]) -> __CodecOutputReturn>( &self, f: __CodecUsingEncodedCallback, ) -> __CodecOutputReturn
Convert self to a slice and then invoke the given closure with it.
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
Source§impl<T: Eq + PartialEq + Ord + PartialOrd> Extend<T> for VecSet<T>
impl<T: Eq + PartialEq + Ord + PartialOrd> Extend<T> for VecSet<T>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<T: Eq + PartialEq + Ord + PartialOrd> FromIterator<T> for VecSet<T>
impl<T: Eq + PartialEq + Ord + PartialOrd> FromIterator<T> for VecSet<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
Source§impl<T: Eq + PartialEq + Ord + PartialOrd> IntoIterator for VecSet<T>
impl<T: Eq + PartialEq + Ord + PartialOrd> IntoIterator for VecSet<T>
Source§impl<T: Ord> Ord for VecSet<T>
impl<T: Ord> Ord for VecSet<T>
Source§impl<T: PartialOrd> PartialOrd for VecSet<T>
impl<T: PartialOrd> PartialOrd for VecSet<T>
impl<T> EncodeLike for VecSet<T>
impl<T: Eq> Eq for VecSet<T>
impl<T> StructuralPartialEq for VecSet<T>
Auto Trait Implementations§
impl<T> Freeze for VecSet<T>
impl<T> RefUnwindSafe for VecSet<T>where
T: RefUnwindSafe,
impl<T> Send for VecSet<T>where
T: Send,
impl<T> Sync for VecSet<T>where
T: Sync,
impl<T> Unpin for VecSet<T>where
T: Unpin,
impl<T> UnwindSafe for VecSet<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T, U> AsByteSlice<T> for U
impl<T, U> AsByteSlice<T> for U
fn as_byte_slice(&self) -> &[u8] ⓘ
Source§impl<T, U> AsMutByteSlice<T> for U
impl<T, U> AsMutByteSlice<T> for U
fn as_mut_byte_slice(&mut self) -> &mut [u8] ⓘ
Source§impl<U> AsMutSliceOf for U
impl<U> AsMutSliceOf for U
fn as_mut_slice_of<T>(&mut self) -> Result<&mut [T], Error>where
T: FromByteSlice,
Source§impl<U> AsSliceOf for U
impl<U> AsSliceOf for U
fn as_slice_of<T>(&self) -> Result<&[T], Error>where
T: FromByteSlice,
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