pub struct Bonds {
pub atom_a: Vec<u32>,
pub atom_b: Vec<u32>,
pub order: Vec<u8>,
pub atom_bond_starts: Vec<u32>,
}Expand description
Bond connectivity stored as SoA (struct-of-arrays).
atom_a and atom_b are atom indices; order is bond order (1 = single, 2 = double, etc.).
After construction the arrays are sorted by atom_a so that
atom_bond_starts[i]..atom_bond_starts[i+1] gives the bond range for atom i.
Fields§
§atom_a: Vec<u32>First atom index for each bond (sorted).
atom_b: Vec<u32>Second atom index for each bond.
order: Vec<u8>Bond order for each bond (1 = single, 2 = double, 3 = triple, etc.).
atom_bond_starts: Vec<u32>CSR-style start index into bonds arrays, indexed by atom.
atom_bond_starts.len() == n_atoms + 1; atom i’s bonds span
atom_bond_starts[i]..atom_bond_starts[i+1].
Implementations§
Source§impl Bonds
impl Bonds
Sourcepub fn from_unsorted(
atom_a: Vec<u32>,
atom_b: Vec<u32>,
order: Vec<u8>,
n_atoms: usize,
) -> Self
pub fn from_unsorted( atom_a: Vec<u32>, atom_b: Vec<u32>, order: Vec<u8>, n_atoms: usize, ) -> Self
Construct from parallel atom_a/atom_b/order vectors.
Sorts bonds by atom_a and builds the atom_bond_starts CSR index.
§Panics
Panics if atom_a, atom_b, and order have different lengths,
or if any atom index is >= n_atoms.
Sourcepub fn bonds_for_atom(
&self,
atom_idx: usize,
) -> impl Iterator<Item = (u32, u8)> + '_
pub fn bonds_for_atom( &self, atom_idx: usize, ) -> impl Iterator<Item = (u32, u8)> + '_
Returns an iterator over (atom_b, order) pairs for all bonds from atom_idx.
Only bonds where atom_idx appears as atom_a are returned. For undirected
traversal, callers should also check the reverse (atom_b side) or store both
directions when constructing.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Bonds
impl RefUnwindSafe for Bonds
impl Send for Bonds
impl Sync for Bonds
impl Unpin for Bonds
impl UnsafeUnpin for Bonds
impl UnwindSafe for Bonds
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