master > master: code-rust - debug logging auslagern
This commit is contained in:
parent
b377120ea8
commit
37f05d1ff0
@ -67,10 +67,7 @@ fn tarjan_visit<T>(gph: &Graph<T>, v: &T, ctx: &mut Context<T>)
|
||||
}
|
||||
}
|
||||
ctx.set_state(v, State::FINISHED);
|
||||
if ctx.debug {
|
||||
let info = ctx.get_info(&v);
|
||||
log_debug!("node, index, component: ({}, {}, {})", info.node, info.index, info.root);
|
||||
}
|
||||
ctx.log_info(&v);
|
||||
|
||||
if ctx.get_index(v) == ctx.get_root(v) {
|
||||
let mut component: Vec<T> = Vec::new();
|
||||
@ -155,21 +152,27 @@ impl<T> Context<T>
|
||||
self.update_infos(u, info);
|
||||
}
|
||||
|
||||
fn get_info(self: &mut Self, u: &T) -> NodeInformation<T> {
|
||||
fn get_info(self: &Self, u: &T) -> NodeInformation<T> {
|
||||
return *self.infos.get(u).unwrap();
|
||||
}
|
||||
|
||||
fn get_state(self: &mut Self, u: &T) -> State {
|
||||
fn get_state(self: &Self, u: &T) -> State {
|
||||
return self.get_info(u).state;
|
||||
}
|
||||
|
||||
fn get_root(self: &mut Self, u: &T) -> usize {
|
||||
fn get_root(self: &Self, u: &T) -> usize {
|
||||
return self.get_info(u).root;
|
||||
}
|
||||
|
||||
fn get_index(self: &mut Self, u: &T) -> usize {
|
||||
fn get_index(self: &Self, u: &T) -> usize {
|
||||
return self.get_info(u).index;
|
||||
}
|
||||
|
||||
fn log_info(self: &Self, u: &T) {
|
||||
if !self.debug { return; }
|
||||
let info = self.get_info(&u);
|
||||
log_debug!("node, index, component: ({}, {}, {})", info.node, info.index, info.root);
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> NodeInformation<T>
|
||||
|
Loading…
x
Reference in New Issue
Block a user