pub struct WrapperHashSet<'a, T, S = RandomState> {
    pub hs: HashSet<T, S>,
    /* private fields */
}
Expand description

A wrapper for the HashSet type which implements more functions. Everything you need to do with a HashSet needs to be done using WrapperHashSet.hs.[function] for now.

Fields§

§hs: HashSet<T, S>

The basic Hashset.

Implementations§

source§

impl<'a, T: Clone + Eq + Hash> WrapperHashSet<'a, T>

source

pub fn wrap(existing: HashSet<T>) -> WrapperHashSet<'a, T>

Wrap a existing HashSet in this Wrapper-struct.

Arguments
  • existing - The existing HashSet.
Returns

A new WrapperHashSet.

Examples
use lib_rapid::math::sets::wrapper_hash_sets::WrapperHashSet;
use std::collections::HashSet;
 
let mut books = HashSet::new();
books.insert("A Dance With Dragons".to_string());
books.insert("1984".to_string());
 
let mut wrapped = WrapperHashSet::wrap(books);
source

pub fn new_subset<F: Fn(&T) -> bool>(&'a self, f: F) -> Self

Creates a new WrapperHashSet from self to which it applies a closure.

Arguments
  • f - The closure after which the new VecSet is created.
Returns

A child WrapperHashSet.

Examples
use lib_rapid::math::sets::wrapper_hash_sets::WrapperHashSet;
use std::collections::HashSet;
 
let mut nums = HashSet::new();
for i in 0..=6 {
    nums.insert(i);
}
 
let wrapped = WrapperHashSet::wrap(nums);
let subset = wrapped.new_subset(|x| x % 2 == 0);
 
assert_eq!(HashSet::from([0, 2, 4, 6]), subset.hs);
source

pub fn has_emerged(&self) -> bool

Lets you check wether a set has a parent (emerged from another set) or not.

Returns

A boolean value which determines if the set is a subset of any other set.

Examples
use lib_rapid::math::sets::wrapper_hash_sets::WrapperHashSet;
use std::collections::HashSet;
 
let mut nums = HashSet::new();
for i in 0..=6 {
    nums.insert(i);
}
 
let wrapped = WrapperHashSet::wrap(nums);
let subset = wrapped.new_subset(|x| x % 2 == 0);
 
assert_eq!(true, subset.has_emerged());
source

pub fn get_superset(&self) -> Option<&Self>

Gets you the optional superset.

Returns

A Option<&VecSet<T>>.

Examples
use lib_rapid::math::sets::wrapper_hash_sets::WrapperHashSet;
use std::collections::HashSet;
 
let mut nums = HashSet::new();
for i in 0..=6 {
    nums.insert(i);
}
 
let wrapped = WrapperHashSet::wrap(nums);
let subset = wrapped.new_subset(|x| x % 2 == 0);
 
assert_eq!(&wrapped, subset.get_superset().unwrap());

Trait Implementations§

source§

impl<'a, T: Debug, S: Debug> Debug for WrapperHashSet<'a, T, S>

source§

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

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

impl<'a, T: Debug> Display for WrapperHashSet<'a, T>

source§

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

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

impl<'a, T: Eq + Hash, S: BuildHasher> PartialEq for WrapperHashSet<'a, T, S>

source§

fn eq(&self, other: &WrapperHashSet<'_, T, S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<'a, T, S> RefUnwindSafe for WrapperHashSet<'a, T, S>

§

impl<'a, T, S> Send for WrapperHashSet<'a, T, S>
where S: Send, T: Send + Sync,

§

impl<'a, T, S> Sync for WrapperHashSet<'a, T, S>
where S: Sync, T: Sync,

§

impl<'a, T, S> Unpin for WrapperHashSet<'a, T, S>
where S: Unpin, T: Unpin,

§

impl<'a, T, S> UnwindSafe for WrapperHashSet<'a, T, S>

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> 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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.