mirror of https://codeberg.org/topola/topola.git
fix(planar-incr-embed): discover all possible paths, including the variants re: weak entries
This commit is contained in:
parent
77969952ff
commit
bb1cfc76d9
|
|
@ -180,25 +180,29 @@ where
|
||||||
// 2. handle rest
|
// 2. handle rest
|
||||||
Some((
|
Some((
|
||||||
start_idx,
|
start_idx,
|
||||||
it.filter_map(move |(section_idx, (ni, eps))| {
|
it.flat_map(move |(section_idx, (ni, eps))| {
|
||||||
// find possible insertion point
|
// find possible insertion point
|
||||||
// (at most one of `eps.len()+1` positions)
|
// (at most one of `eps.len()+1` positions)
|
||||||
let mut pos = if stack.is_empty() { Some(0) } else { None };
|
(if stack.is_empty() { Some(0) } else { None })
|
||||||
for (n, i) in eps.iter().enumerate() {
|
.into_iter()
|
||||||
handle_lifo_relaxed(&mut stack, i);
|
.chain(eps.iter().enumerate().filter_map(|(n, i)| {
|
||||||
if pos.is_none() && stack.is_empty() {
|
handle_lifo_relaxed(&mut stack, i);
|
||||||
pos = Some(n + 1);
|
if stack.is_empty() {
|
||||||
}
|
Some(n + 1)
|
||||||
}
|
} else {
|
||||||
pos.map(|insert_pos| {
|
None
|
||||||
(
|
}
|
||||||
ni,
|
}))
|
||||||
OtherEnd {
|
.map(move |insert_pos| {
|
||||||
section_idx,
|
(
|
||||||
insert_pos,
|
ni.clone(),
|
||||||
},
|
OtherEnd {
|
||||||
)
|
section_idx,
|
||||||
})
|
insert_pos,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
---
|
||||||
|
source: crates/planar-incr-embed/src/planarr/tests.rs
|
||||||
|
expression: "s_.find_all_other_ends(&0, 0, false).unwrap().1.collect::<Vec<_>>()"
|
||||||
|
---
|
||||||
|
[
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
"section_idx": 1,
|
||||||
|
"insert_pos": 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"section_idx": 2,
|
||||||
|
"insert_pos": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
"section_idx": 2,
|
||||||
|
"insert_pos": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
@ -148,3 +148,20 @@ fn simple01() {
|
||||||
assert_eq!(s_.insert_path(&1, 2, &2, 'd'), Ok(1));
|
assert_eq!(s_.insert_path(&1, 2, &2, 'd'), Ok(1));
|
||||||
assert_compact_json_snapshot!(s.0);
|
assert_compact_json_snapshot!(s.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn weak00() {
|
||||||
|
let mut s = PlanarArrangement::<_, _, ()>::from_node_indices(0..3);
|
||||||
|
let mut s_ = s.as_mut();
|
||||||
|
s_.0[2].1.reversed = true;
|
||||||
|
s_.0[2].1.with_borrow_mut(|j| {
|
||||||
|
j.inner.push(RelaxedPath::Weak(()));
|
||||||
|
});
|
||||||
|
assert_eq!(s_.insert_path(&0, 0, &1, 'a'), Ok(0));
|
||||||
|
assert_eq!(s_.insert_path(&0, 0, &1, 'b'), Ok(0));
|
||||||
|
assert_compact_json_snapshot!(s_
|
||||||
|
.find_all_other_ends(&0, 0, false)
|
||||||
|
.unwrap()
|
||||||
|
.1
|
||||||
|
.collect::<Vec<_>>());
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue