pub struct PostDominatorResult {
pub post_dom: AHashMap<i64, AHashSet<i64>>,
pub ipdom: AHashMap<i64, Option<i64>>,
}Expand description
Result of post-dominator computation.
Contains both full post-dominance sets and the immediate post-dominator tree.
The post-dominance sets are complete: for each node n, post_dom[n] contains all
nodes that post-dominate n (including n itself). The immediate post-dominator
tree is a compact representation: ipdom[n] is the parent of n in the
post-dominator tree (None for exit nodes).
Fields§
§post_dom: AHashMap<i64, AHashSet<i64>>Full post-dominance sets: node -> set of its post-dominators.
For each node n, post_dom[n] contains all nodes d such that every
path from n to exit passes through d. Every node post-dominates itself,
and exit nodes post-dominate all nodes that can reach them.
ipdom: AHashMap<i64, Option<i64>>Immediate post-dominator tree: node -> immediate post-dominator.
For each node n (except exit), ipdom[n] is the unique strict post-dominator
of n that is closest to n. Exit nodes have ipdom[exit] = None.
This forms a tree rooted at the exit node (or virtual exit for multiple exits).
Implementations§
Source§impl PostDominatorResult
impl PostDominatorResult
Sourcepub fn post_dominates(&self, post_dominator: i64, node: i64) -> bool
pub fn post_dominates(&self, post_dominator: i64, node: i64) -> bool
Checks if one node post-dominates another.
Returns true if post_dominator post-dominates node (every path from
node to exit passes through post_dominator). Every node post-dominates itself.
§Arguments
post_dominator- Potential post-dominator node IDnode- Node ID to check post-dominance for
§Returns
true if post_dominator post-dominates node, false otherwise.
§Example
let result = post_dominators(&graph, exit)?;
assert!(result.post_dominates(exit, 0)); // Exit post-dominates all
assert!(result.post_dominates(5, 5)); // Every node post-dominates itselfSourcepub fn immediate_post_dominator(&self, node: i64) -> Option<i64>
pub fn immediate_post_dominator(&self, node: i64) -> Option<i64>
Gets the immediate post-dominator of a node.
Returns None if the node has no immediate post-dominator (exit nodes have
None). Returns Some(ipdom) if the node has an immediate post-dominator.
§Arguments
node- Node ID to get immediate post-dominator for
§Returns
Some(ipdom) if node has an immediate post-dominator, None for exit nodes.
§Example
let result = post_dominators(&graph, exit)?;
assert_eq!(result.immediate_post_dominator(exit), None); // Exit has no ipdom
assert!(result.immediate_post_dominator(child).is_some()); // Others have ipdomTrait Implementations§
Source§impl Clone for PostDominatorResult
impl Clone for PostDominatorResult
Source§fn clone(&self) -> PostDominatorResult
fn clone(&self) -> PostDominatorResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PostDominatorResult
impl RefUnwindSafe for PostDominatorResult
impl Send for PostDominatorResult
impl Sync for PostDominatorResult
impl Unpin for PostDominatorResult
impl UnwindSafe for PostDominatorResult
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more