VecSortedSet

Struct VecSortedSet 

Source
pub struct VecSortedSet<T>(/* private fields */);
Expand description

an array-set. very efficient for small sets.

for explanations about the methods, see BTreeSet and Vec.

Implementations§

Source§

impl<T> VecSortedSet<T>
where T: Ord,

Source

pub fn new() -> Self

Source

pub fn with_capacity(n: usize) -> Self

Source

pub fn capacity(&self) -> usize

Source

pub fn reserve(&mut self, n: usize)

Source

pub fn shrink_to_fit(&mut self)

Source

pub fn clear(&mut self)

Source

pub fn contains<Q>(&self, e: &Q) -> bool
where T: Borrow<Q>, Q: Ord + ?Sized,

O(log(len))

Source

pub fn get<Q>(&self, e: &Q) -> Option<&T>
where T: Borrow<Q>, Q: Ord + ?Sized,

O(log(len))

Source

pub fn get_mut<Q>(&mut self, e: &Q) -> Option<&mut T>
where T: Borrow<Q>, Q: Ord + ?Sized,

O(log(len))

Source

pub fn insert(&mut self, e: T) -> Option<T>

O(log(len)) when e already exists. O(len) for inserting a new element, caused by shifting all elements after it, which can be avoided by always inserting in order.

Source

pub fn remove<Q>(&mut self, e: &Q) -> Option<T>
where T: Borrow<Q>, Q: Ord + ?Sized,

O(log(len)) when e does not exist. O(len) for removing an element, because of the need for shifting all elements after it.

Source

pub fn append(&mut self, other: &mut VecSortedSet<T>)

Source

pub fn reserve_exact(&mut self, n: usize)

Source

pub fn pop(&mut self) -> Option<T>

Source

pub fn truncate(&mut self, n: usize)

Source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&T) -> bool,

Source

pub fn split_off(&mut self, at: usize) -> VecSortedSet<T>

Source

pub fn is_disjoint(&self, other: &VecSortedSet<T>) -> bool

Source

pub fn is_subset(&self, other: &VecSortedSet<T>) -> bool

Source

pub fn is_superset(&self, other: &VecSortedSet<T>) -> bool

Source

pub fn union<'a>(&'a self, other: &'a VecSortedSet<T>) -> Union<'a, T>

Source

pub fn intersection<'a>( &'a self, other: &'a VecSortedSet<T>, ) -> Intersection<'a, T>

Source

pub fn difference<'a>(&'a self, other: &'a VecSortedSet<T>) -> Difference<'a, T>

Source

pub fn symmetric_difference<'a>( &'a self, other: &'a VecSortedSet<T>, ) -> SymmetricDifference<'a, T>

Source§

impl<T> VecSortedSet<T>

Source

pub fn view_content<'a>(&'a self) -> &'a Vec<T>

a view for the underlying vec. &self methods for Vec such as get and split can be accessed through this.

Source

pub fn iter(&self) -> Iter<'_, T>

iterate over the underlying vec.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl<'a, 'b, T> BitAnd<&'b VecSortedSet<T>> for &'a VecSortedSet<T>
where T: Ord + Clone,

Source§

fn bitand(self, other: &VecSortedSet<T>) -> VecSortedSet<T>

intersection with cloned members.

§example
use protocoll::set::VecSortedSet;
let s1:VecSortedSet<_> = vec![1,2,3].into_iter().collect();
let s2:VecSortedSet<_> = vec![2,3,4].into_iter().collect();
assert_eq!((&s1 & &s2).view_content(), &[2,3]);
Source§

type Output = VecSortedSet<T>

The resulting type after applying the & operator.
Source§

impl<T> BitAnd for VecSortedSet<T>
where T: Ord,

Source§

fn bitand(self, other: VecSortedSet<T>) -> VecSortedSet<T>

intersection.

§example
use protocoll::set::VecSortedSet;
let s1:VecSortedSet<_> = vec![1,2,3].into_iter().collect();
let s2:VecSortedSet<_> = vec![2,3,4].into_iter().collect();
assert_eq!((s1 & s2).view_content(), &[2,3]);
Source§

type Output = VecSortedSet<T>

The resulting type after applying the & operator.
Source§

impl<'a, 'b, T> BitOr<&'b VecSortedSet<T>> for &'a VecSortedSet<T>
where T: Ord + Clone,

Source§

fn bitor(self, other: &VecSortedSet<T>) -> VecSortedSet<T>

union with cloned members.

§example
use protocoll::set::VecSortedSet;
let s1:VecSortedSet<_> = vec![1,2,3].into_iter().collect();
let s2:VecSortedSet<_> = vec![2,3,4].into_iter().collect();
assert_eq!((&s1 | &s2).view_content(), &[1,2,3,4]);
Source§

type Output = VecSortedSet<T>

The resulting type after applying the | operator.
Source§

impl<T> BitOr for VecSortedSet<T>
where T: Ord,

Source§

fn bitor(self, other: VecSortedSet<T>) -> VecSortedSet<T>

union.

§example
use protocoll::set::VecSortedSet;
let s1:VecSortedSet<_> = vec![1,2,3].into_iter().collect();
let s2:VecSortedSet<_> = vec![2,3,4].into_iter().collect();
assert_eq!((s1 | s2).view_content(), &[1,2,3,4]);
Source§

type Output = VecSortedSet<T>

The resulting type after applying the | operator.
Source§

impl<'a, 'b, T> BitXor<&'b VecSortedSet<T>> for &'a VecSortedSet<T>
where T: Ord + Clone,

Source§

fn bitxor(self, other: &VecSortedSet<T>) -> VecSortedSet<T>

symmetric difference with cloned members.

§example
use protocoll::set::VecSortedSet;
let s1:VecSortedSet<_> = vec![1,2,3].into_iter().collect();
let s2:VecSortedSet<_> = vec![2,3,4].into_iter().collect();
assert_eq!((&s1 ^ &s2).view_content(), &[1,4]);
Source§

type Output = VecSortedSet<T>

The resulting type after applying the ^ operator.
Source§

impl<T> BitXor for VecSortedSet<T>
where T: Ord,

Source§

fn bitxor(self, other: VecSortedSet<T>) -> VecSortedSet<T>

symmetric difference.

§example
use protocoll::set::VecSortedSet;
let s1:VecSortedSet<_> = vec![1,2,3].into_iter().collect();
let s2:VecSortedSet<_> = vec![2,3,4].into_iter().collect();
assert_eq!((s1 ^ s2).view_content(), &[1,4]);
Source§

type Output = VecSortedSet<T>

The resulting type after applying the ^ operator.
Source§

impl<T: Clone> Clone for VecSortedSet<T>

Source§

fn clone(&self) -> VecSortedSet<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for VecSortedSet<T>
where T: Ord + Debug,

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for VecSortedSet<T>

Source§

fn default() -> VecSortedSet<T>

Returns the “default value” for a type. Read more
Source§

impl<'a, T> Extend<&'a T> for VecSortedSet<T>
where T: Ord + Copy,

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = &'a T>,

Extends a collection with the contents of an iterator. Read more
Source§

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)

🔬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> Extend<T> for VecSortedSet<T>
where T: Ord,

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = T>,

Extends a collection with the contents of an iterator. Read more
Source§

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)

🔬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> FromIterator<T> for VecSortedSet<T>
where T: Ord,

Source§

fn from_iter<I>(iter: I) -> VecSortedSet<T>
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
Source§

impl<T: Hash> Hash for VecSortedSet<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, T, Q> Index<&'a Q> for VecSortedSet<T>
where T: Ord + Borrow<Q>, Q: Ord + ?Sized,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, k: &Q) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T: 'a> IntoIterator for &'a VecSortedSet<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Iter<'a, T>

Creates an iterator from a value. Read more
Source§

impl<T> IntoIterator for VecSortedSet<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> IntoIter<T>

Creates an iterator from a value. Read more
Source§

impl<T: Ord> Ord for VecSortedSet<T>

Source§

fn cmp(&self, other: &VecSortedSet<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq> PartialEq for VecSortedSet<T>

Source§

fn eq(&self, other: &VecSortedSet<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd> PartialOrd for VecSortedSet<T>

Source§

fn partial_cmp(&self, other: &VecSortedSet<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> Set<T> for VecSortedSet<T>
where T: Ord,

Source§

fn fun<'a, Q>(&'a self) -> Box<dyn Fn(&Q) -> Option<&'a T> + 'a>
where T: Borrow<Q>, Q: Ord + ?Sized,

a set maps from items to themselves.
Source§

fn inc(self, i: T) -> Self

adds item i. Read more
Source§

fn dec<Q>(self, i: &Q) -> Self
where T: Borrow<Q>, Q: Ord + ?Sized,

removes item i. Read more
Source§

fn zero(self) -> Self

clear.
Source§

fn shrink(self) -> Self

shrink_to_fit.
Source§

fn plus<I>(self, coll: I) -> Self
where I: IntoIterator<Item = T>,

pours another collection into this one. Read more
Source§

impl<'a, 'b, T> Sub<&'b VecSortedSet<T>> for &'a VecSortedSet<T>
where T: Ord + Clone,

Source§

fn sub(self, other: &VecSortedSet<T>) -> VecSortedSet<T>

difference with cloned members.

§example
use protocoll::set::VecSortedSet;
let s1:VecSortedSet<_> = vec![1,2,3].into_iter().collect();
let s2:VecSortedSet<_> = vec![2,3,4].into_iter().collect();
assert_eq!((&s1 - &s2).view_content(), &[1]);
Source§

type Output = VecSortedSet<T>

The resulting type after applying the - operator.
Source§

impl<T> Sub for VecSortedSet<T>
where T: Ord,

Source§

fn sub(self, other: VecSortedSet<T>) -> VecSortedSet<T>

difference.

§example
use protocoll::set::VecSortedSet;
let s1:VecSortedSet<_> = vec![1,2,3].into_iter().collect();
let s2:VecSortedSet<_> = vec![2,3,4].into_iter().collect();
assert_eq!((s1 - s2).view_content(), &[1]);
Source§

type Output = VecSortedSet<T>

The resulting type after applying the - operator.
Source§

impl<T: Eq> Eq for VecSortedSet<T>

Source§

impl<T> StructuralPartialEq for VecSortedSet<T>

Auto Trait Implementations§

§

impl<T> Freeze for VecSortedSet<T>

§

impl<T> RefUnwindSafe for VecSortedSet<T>
where T: RefUnwindSafe,

§

impl<T> Send for VecSortedSet<T>
where T: Send,

§

impl<T> Sync for VecSortedSet<T>
where T: Sync,

§

impl<T> Unpin for VecSortedSet<T>
where T: Unpin,

§

impl<T> UnwindSafe for VecSortedSet<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.