Trait zfc::Set

source ·
pub trait Set {
    type Elem: Eq + ?Sized;

    // Required methods
    fn bounded_cardinality(&self) -> BoundedCardinality;
    fn contains<Q>(&self, elem: &Q) -> bool
       where Q: Borrow<Self::Elem> + Eq + ?Sized;
    fn is_proper_subset(&self, val: &Self) -> bool;
    fn is_subset(&self, val: &Self) -> bool;

    // Provided methods
    fn cardinality(&self) -> Option<Cardinality> { ... }
    fn is_proper_superset(&self, val: &Self) -> bool { ... }
    fn is_superset(&self, val: &Self) -> bool { ... }
    fn is_proper_subset_iter<T>(&self, val: &T) -> bool
       where Self::Elem: Borrow<T::Elem> + PartialEq<T::Elem>,
             for<'a> &'a Self: IntoIterator<Item = &'a Self::Elem>,
             T: Set + ?Sized,
             T::Elem: PartialEq<Self::Elem> { ... }
    fn is_subset_iter<T>(&self, val: &T) -> bool
       where Self::Elem: Borrow<T::Elem> + PartialEq<T::Elem>,
             for<'a> &'a Self: IntoIterator<Item = &'a Self::Elem>,
             T: Set + ?Sized,
             T::Elem: PartialEq<Self::Elem> { ... }
    fn is_proper_superset_iter<T>(&self, val: &T) -> bool
       where Self::Elem: PartialEq<T::Elem>,
             T: Set + ?Sized,
             for<'a> &'a T: IntoIterator<Item = &'a T::Elem>,
             T::Elem: Borrow<Self::Elem> + PartialEq<Self::Elem> { ... }
    fn is_superset_iter<T>(&self, val: &T) -> bool
       where Self::Elem: PartialEq<T::Elem>,
             T: Set + ?Sized,
             for<'a> &'a T: IntoIterator<Item = &'a T::Elem>,
             T::Elem: Borrow<Self::Elem> + PartialEq<Self::Elem> { ... }
}
Expand description

Represents a set according to Zermelo–Fraenkel set theory with the axiom of choice (ZFC). Note that elements in a Set must not be distinguishable by order or frequency, so care must be taken in its implementation if the implementing type exposes an API that distinguishes between the order or frequency of Elem (e.g., Vec<T> where Elem = T).

Required Associated Types§

source

type Elem: Eq + ?Sized

The elements that make up the set. Per ZFC, this must not be the same type as Self nor a recursive type based on Self.

Required Methods§

source

fn bounded_cardinality(&self) -> BoundedCardinality

Returns the bounded cardinality of self.

source

fn contains<Q>(&self, elem: &Q) -> bool
where Q: Borrow<Self::Elem> + Eq + ?Sized,

Returns true iff Self contains elem.

source

fn is_proper_subset(&self, val: &Self) -> bool

Must conform to the following properties:

  • Irreflexivity.
  • Antisymmetry.
  • Transitivity.
  • a, b: Self, a.is_proper_subset(b)⇒ ∀e: Elem | a.contains(e), b.contains(e) ∧ ∃f: Elem, b.contains(f) && !a.contains(f).
  • a, b: Self, a.is_proper_subset(b)a.is_subset(b).
  • a, b: Self, a.is_proper_subset(b)b.is_proper_superset(a).
source

fn is_subset(&self, val: &Self) -> bool

Must conform to the following properties:

  • Reflexivity.
  • Antisymmetry.
  • Transitivity.
  • a, b: Self, a.is_subset(b)⇒ ∀e: Elem | a.contains(e), b.contains(e).
  • a, b: Self, a.is_subset(b)b.is_superset(a).

Provided Methods§

source

fn cardinality(&self) -> Option<Cardinality>

Returns the cardinality of self if it is known exactly.

The following property must be true:

  • self.cardinality().unwrap() == self.bounded_cardinality().lower()self.bounded_cardinality().lower() == self.bounded_cardinality().upper().
source

fn is_proper_superset(&self, val: &Self) -> bool

Must conform to the following properties:

  • Irreflexivity.
  • Antisymmetry.
  • Transitivity.
  • a, b: Self, a.is_proper_superset(b)a.is_superset(b).
source

fn is_superset(&self, val: &Self) -> bool

Must conform to the following properties:

  • Reflexivity.
  • Antisymmetry.
  • Transitivity.
source

fn is_proper_subset_iter<T>(&self, val: &T) -> bool
where Self::Elem: Borrow<T::Elem> + PartialEq<T::Elem>, for<'a> &'a Self: IntoIterator<Item = &'a Self::Elem>, T: Set + ?Sized, T::Elem: PartialEq<Self::Elem>,

source

fn is_subset_iter<T>(&self, val: &T) -> bool
where Self::Elem: Borrow<T::Elem> + PartialEq<T::Elem>, for<'a> &'a Self: IntoIterator<Item = &'a Self::Elem>, T: Set + ?Sized, T::Elem: PartialEq<Self::Elem>,

source

fn is_proper_superset_iter<T>(&self, val: &T) -> bool
where Self::Elem: PartialEq<T::Elem>, T: Set + ?Sized, for<'a> &'a T: IntoIterator<Item = &'a T::Elem>, T::Elem: Borrow<Self::Elem> + PartialEq<Self::Elem>,

source

fn is_superset_iter<T>(&self, val: &T) -> bool
where Self::Elem: PartialEq<T::Elem>, T: Set + ?Sized, for<'a> &'a T: IntoIterator<Item = &'a T::Elem>, T::Elem: Borrow<Self::Elem> + PartialEq<Self::Elem>,

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

§

type Elem = T

source§

fn cardinality(&self) -> Option<Cardinality>

source§

fn bounded_cardinality(&self) -> BoundedCardinality

source§

fn contains<Q>(&self, elem: &Q) -> bool
where Q: Borrow<Self::Elem> + Eq + ?Sized,

source§

fn is_proper_subset(&self, val: &Self) -> bool

source§

fn is_subset(&self, val: &Self) -> bool

source§

impl<T> Set for Range<T>
where T: Ord, for<'a, 'b> &'a T: Sub<&'b T>, for<'a, 'b> <&'a T as Sub<&'b T>>::Output: Into<BigUint>,

§

type Elem = T

source§

fn cardinality(&self) -> Option<Cardinality>

source§

fn bounded_cardinality(&self) -> BoundedCardinality

source§

fn contains<Q>(&self, elem: &Q) -> bool
where Q: Borrow<Self::Elem> + Eq + ?Sized,

source§

fn is_proper_subset(&self, val: &Self) -> bool

source§

fn is_subset(&self, val: &Self) -> bool

source§

impl<T> Set for RangeInclusive<T>
where T: Ord, for<'a, 'b> &'a T: Sub<&'b T>, for<'a, 'b> <&'a T as Sub<&'b T>>::Output: Into<BigUint>,

§

type Elem = T

source§

fn cardinality(&self) -> Option<Cardinality>

source§

fn bounded_cardinality(&self) -> BoundedCardinality

source§

fn contains<Q>(&self, elem: &Q) -> bool
where Q: Borrow<Self::Elem> + Eq + ?Sized,

source§

fn is_proper_subset(&self, val: &Self) -> bool

source§

fn is_subset(&self, val: &Self) -> bool

source§

impl<T, S> Set for HashSet<T, S>
where T: Eq + Hash, S: BuildHasher,

Available on crate feature std only.
§

type Elem = T

source§

fn cardinality(&self) -> Option<Cardinality>

source§

fn bounded_cardinality(&self) -> BoundedCardinality

source§

fn contains<Q>(&self, elem: &Q) -> bool
where Q: Borrow<Self::Elem> + Eq + ?Sized,

source§

fn is_proper_subset(&self, val: &Self) -> bool

source§

fn is_subset(&self, val: &Self) -> bool

Implementors§