pub struct TransitiveRelation<T> {
builder: Frozen<TransitiveRelationBuilder<T>>,
closure: Frozen<BitMatrix<usize, usize>>,
}
Fields§
§builder: Frozen<TransitiveRelationBuilder<T>>
§closure: Frozen<BitMatrix<usize, usize>>
Implementations§
source§impl<T: Eq + Hash + Copy> TransitiveRelation<T>
impl<T: Eq + Hash + Copy> TransitiveRelation<T>
sourcepub fn maybe_map<F, U>(&self, f: F) > Option<TransitiveRelation<U>>
pub fn maybe_map<F, U>(&self, f: F) > Option<TransitiveRelation<U>>
Applies the (partial) function to each edge and returns a new relation including transitive closures.
sourcepub fn reachable_from(&self, a: T) > Vec<T>
pub fn reachable_from(&self, a: T) > Vec<T>
Thinking of x R y
as an edge x > y
in a graph, this
returns all things reachable from a
.
Really this probably ought to be impl Iterator<Item = &T>
, but
I’m too lazy to make that work, and – given the caching
strategy – it’d be a touch tricky anyhow.
sourcepub fn postdom_upper_bound(&self, a: T, b: T) > Option<T>
pub fn postdom_upper_bound(&self, a: T, b: T) > Option<T>
Picks what I am referring to as the “postdominating”
upperbound for a
and b
. This is usually the least upper
bound, but in cases where there is no single least upper
bound, it is the “mutual immediate postdominator”, if you
imagine a graph where a < b
means a > b
.
This function is needed because region inference currently requires that we produce a single “UB”, and there is no best choice for the LUB. Rather than pick arbitrarily, I pick a less good, but predictable choice. This should help ensure that region inference yields predictable results (though it itself is not fully sufficient).
Examples are probably clearer than any prose I could write
(there are corresponding tests below, btw). In each case,
the query is postdom_upper_bound(a, b)
:
// Returns Some(x), which is also LUB.
a > a1 > x
^

b > b1 +
// Returns `Some(x)`, which is not LUB (there is none)
// diagonal edges run lefttoright.
a > a1 > x
\/ ^
/\ 
b > b1 +
// Returns `None`.
a > a1
b > b1
sourcepub fn mutual_immediate_postdominator(&self, mubs: Vec<T>) > Option<T>
pub fn mutual_immediate_postdominator(&self, mubs: Vec<T>) > Option<T>
Viewing the relation as a graph, computes the “mutual
immediate postdominator” of a set of points (if one
exists). See postdom_upper_bound
for details.
sourcepub fn minimal_upper_bounds(&self, a: T, b: T) > Vec<T>
pub fn minimal_upper_bounds(&self, a: T, b: T) > Vec<T>
Returns the set of bounds X
such that:
a < X
andb < X
 there is no
Y != X
such thata < Y
andY < X
 except for the case where
X < a
(i.e., a strongly connected component in the graph). In that case, the smallest representative of the SCC is returned (as determined by the internal indices).
 except for the case where
Note that this set can, in principle, have any size.
sourcepub fn parents(&self, a: T) > Vec<T>
pub fn parents(&self, a: T) > Vec<T>
Given an element A, returns the maximal set {B} of elements B such that
 A != B
 A R B is true
 for each i, j:
B[i]
RB[j]
does not hold
The intuition is that this moves “one step up” through a lattice
(where the relation is encoding the <=
relation for the lattice).
So e.g., if the relation is >
and we have
a > b > d > f
 ^
+> c > e +
then parents(a)
returns [b, c]
. The postdom_parent
function
would further reduce this to just f
.
fn with_closure<OP, R>(&self, op: OP) > R
sourcepub fn base_edges(&self) > impl Iterator<Item = (T, T)> + '_
pub fn base_edges(&self) > impl Iterator<Item = (T, T)> + '_
Lists all the base edges in the graph: the initial nontransitive set of element relations, which will be later used as the basis for the transitive closure computation.
Trait Implementations§
source§impl<T: Clone> Clone for TransitiveRelation<T>
impl<T: Clone> Clone for TransitiveRelation<T>
source§impl<T: Debug> Debug for TransitiveRelation<T>
impl<T: Debug> Debug for TransitiveRelation<T>
Auto Trait Implementations§
impl<T> DynSend for TransitiveRelation<T>where
T: DynSend,
impl<T> DynSync for TransitiveRelation<T>where
T: DynSync,
impl<T> Freeze for TransitiveRelation<T>
impl<T> RefUnwindSafe for TransitiveRelation<T>where
T: RefUnwindSafe,
impl<T> Send for TransitiveRelation<T>where
T: Send,
impl<T> Sync for TransitiveRelation<T>where
T: Sync,
impl<T> Unpin for TransitiveRelation<T>where
T: Unpin,
impl<T> UnwindSafe for TransitiveRelation<T>where
T: UnwindSafe,
Blanket Implementations§
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) > Instrumented<Self>
fn instrument(self, span: Span) > Instrumented<Self>
source§fn in_current_span(self) > Instrumented<Self>
fn in_current_span(self) > Instrumented<Self>
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) > WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) > WithDispatch<Self>
source§fn with_current_subscriber(self) > WithDispatch<Self>
fn with_current_subscriber(self) > WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 128 bytes