pub struct UnionFind<Map>(/* private fields */);
Expand description

Union-find lattice.

Each value of K in the map represents an item in a set. When two lattices instances are merged, any sets with common elements will be unioned together.

[Self::union(a, b)] unions two sets together, which is equivalent to merging in a UnionFindSingletonMap atom of (a, b) (or (b, a)).

Any union-find consisting only of singleton sets is bottom.

§Hasse diagram of partitions of a set of size four:

Implementations§

source§

impl<Map> UnionFind<Map>

source

pub fn new(val: Map) -> Self

Create a new UnionFind from a Map.

source

pub fn new_from(val: impl Into<Map>) -> Self

Create a new UnionFind from an Into<Map>.

source

pub fn as_reveal_ref(&self) -> &Map

Reveal the inner value as a shared reference.

source

pub fn as_reveal_mut(&mut self) -> &mut Map

Reveal the inner value as an exclusive reference.

source

pub fn into_reveal(self) -> Map

Gets the inner by value, consuming self.

source§

impl<Map, K> UnionFind<Map>
where Map: MapMut<K, Cell<K>, Key = K, Item = Cell<K>>, K: Copy + Eq,

source

pub fn union(&mut self, a: K, b: K) -> Min<bool>

Union the sets containg a and b.

Returns true if the sets changed, false if a and b were already in the same set. Once this returns false it will always return false for the same a and b, therefore it returns a Min<bool> lattice.

source§

impl<MapSelf, K> UnionFind<MapSelf>
where MapSelf: Map<K, Cell<K>, Key = K, Item = Cell<K>>, K: Copy + Eq,

source

pub fn same(&self, a: K, b: K) -> Max<bool>

Returns if a and b are in the same set.

This method is monotonic: once this returns true it will always return true for the same a and b, therefore it returns a Max<bool> lattice.

Trait Implementations§

source§

impl<Map, K> Atomize for UnionFind<Map>
where Map: 'static + MapMut<K, Cell<K>, Key = K, Item = Cell<K>> + IntoIterator<Item = (K, Cell<K>)>, K: 'static + Copy + Eq,

§

type Atom = UnionFind<SingletonMap<K, Cell<K>>>

The type of atoms for this lattice.
§

type AtomIter = Box<dyn Iterator<Item = <UnionFind<Map> as Atomize>::Atom>>

The iter type iterating the antichain atoms.
source§

fn atomize(self) -> Self::AtomIter

Atomize self: convert into an iter of atoms. Read more
source§

impl<Map: Clone> Clone for UnionFind<Map>

source§

fn clone(&self) -> UnionFind<Map>

Returns a copy 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<Map: Debug> Debug for UnionFind<Map>

source§

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

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

impl<Map> DeepReveal for UnionFind<Map>

§

type Revealed = Map

The underlying type when revealed.
source§

fn deep_reveal(self) -> Self::Revealed

Reveals the underlying lattice types recursively.
source§

impl<Map: Default> Default for UnionFind<Map>

source§

fn default() -> UnionFind<Map>

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

impl<'de, Map> Deserialize<'de> for UnionFind<Map>
where Map: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<Map, K> IsBot for UnionFind<Map>
where Map: MapIter<Key = K, Item = Cell<K>>, K: Copy + Eq,

source§

fn is_bot(&self) -> bool

Returns if self is lattice bottom (⊥). Read more
source§

impl<Map> IsTop for UnionFind<Map>

source§

fn is_top(&self) -> bool

Returns if self is lattice top (⊤). Read more
source§

impl<MapSelf, MapOther, K> LatticeFrom<UnionFind<MapOther>> for UnionFind<MapSelf>
where MapSelf: Keyed<Key = K, Item = Cell<K>> + FromIterator<(K, Cell<K>)>, MapOther: IntoIterator<Item = (K, Cell<K>)>, K: Copy + Eq,

source§

fn lattice_from(other: UnionFind<MapOther>) -> Self

Convert from the Other lattice into Self.
source§

impl<MapSelf, MapOther, K> Merge<UnionFind<MapOther>> for UnionFind<MapSelf>
where MapSelf: MapMut<K, Cell<K>, Key = K, Item = Cell<K>>, MapOther: IntoIterator<Item = (K, Cell<K>)>, K: Copy + Eq,

source§

fn merge(&mut self, other: UnionFind<MapOther>) -> bool

Merge other into the self lattice. Read more
source§

fn merge_owned(this: Self, delta: Other) -> Self
where Self: Sized,

Merge this and delta together, returning the new value.
source§

impl<MapSelf, MapOther, K> PartialEq<UnionFind<MapOther>> for UnionFind<MapSelf>
where MapSelf: MapMut<K, Cell<K>, Key = K, Item = Cell<K>> + MapIter, MapOther: MapMut<K, Cell<K>, Key = K, Item = Cell<K>> + MapIter, K: Copy + Eq,

source§

fn eq(&self, other: &UnionFind<MapOther>) -> 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.
source§

impl<MapSelf, MapOther, K> PartialOrd<UnionFind<MapOther>> for UnionFind<MapSelf>
where MapSelf: MapMut<K, Cell<K>, Key = K, Item = Cell<K>> + MapIter, MapOther: MapMut<K, Cell<K>, Key = K, Item = Cell<K>> + MapIter, K: Copy + Eq,

source§

fn partial_cmp(&self, other: &UnionFind<MapOther>) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<Map> Serialize for UnionFind<Map>
where Map: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<Map: Copy> Copy for UnionFind<Map>

source§

impl<Map> Eq for UnionFind<Map>
where Self: PartialEq,

source§

impl<MapSelf, MapOther> LatticeOrd<UnionFind<MapOther>> for UnionFind<MapSelf>
where Self: PartialOrd<UnionFind<MapOther>>,

Auto Trait Implementations§

§

impl<Map> Freeze for UnionFind<Map>
where Map: Freeze,

§

impl<Map> RefUnwindSafe for UnionFind<Map>
where Map: RefUnwindSafe,

§

impl<Map> Send for UnionFind<Map>
where Map: Send,

§

impl<Map> Sync for UnionFind<Map>
where Map: Sync,

§

impl<Map> Unpin for UnionFind<Map>
where Map: Unpin,

§

impl<Map> UnwindSafe for UnionFind<Map>
where Map: 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> 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<This, Other> NaiveLatticeOrd<Other> for This
where This: Clone + Merge<Other>, Other: Clone + Merge<This>,

source§

fn naive_cmp(&self, other: &Rhs) -> Option<Ordering>

Naive compare based on the Merge::merge method. This method can be very inefficient; use PartialOrd::partial_cmp instead. Read more
source§

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

§

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

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> Lattice for T