1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use super::sieve_trait::Sieve;
/// Bulk arrow insertion helpers for [`Sieve`] implementations.
///
/// These methods allow inserting many edges in one pass while
/// pre-reserving capacities and invalidating caches only once.
pub trait SieveBuildExt: Sieve {
/// Fallible strict bulk insertion. Exact duplicates are no-ops and any
/// payload conflict is returned instead of being overwritten.
fn try_add_arrows_from<I>(&mut self, edges: I) -> Result<(), crate::mesh_error::MeshSieveError>
where
I: IntoIterator<Item = (Self::Point, Self::Point, Self::Payload)>,
{
for (src, dst, payload) in edges {
self.add_arrow(src, dst, payload)?;
}
Ok(())
}
/// Fallible strict bulk insertion preserving input order and duplicate
/// identity semantics.
fn try_add_arrows_dedup_from<I>(
&mut self,
edges: I,
) -> Result<(), crate::mesh_error::MeshSieveError>
where
I: IntoIterator<Item = (Self::Point, Self::Point, Self::Payload)>,
{
self.try_add_arrows_from(edges)
}
/// Insert many arrows at once.
///
/// For repeated `(src,dst)` pairs the last payload wins.
fn add_arrows_from<I>(&mut self, edges: I)
where
I: IntoIterator<Item = (Self::Point, Self::Point, Self::Payload)>;
/// Insert many arrows, deduplicating identical `(src,dst)` pairs prior to
/// insertion. If duplicates are present in the input, the last payload wins.
fn add_arrows_dedup_from<I>(&mut self, edges: I)
where
I: IntoIterator<Item = (Self::Point, Self::Point, Self::Payload)>;
}