Skip to main content

MolView

Struct MolView 

Source
pub struct MolView<'a> { /* private fields */ }
Expand description

批中单个分子的零拷贝视图。

所有下标参数与返回值都是分子内局部下标(0 起)。

Implementations§

Source§

impl<'a> MolView<'a>

Source

pub fn index(&self) -> u32

该分子在批中的下标

Source

pub fn batch(&self) -> &'a MolBatch

所属的批

Source

pub fn num_atoms(&self) -> usize

原子数

Source

pub fn num_bonds(&self) -> usize

键数

Source

pub fn is_empty(&self) -> bool

是否为空分子

Source

pub fn name(&self) -> Option<&'a str>

分子名

Source

pub fn global_atom(&self, local: u32) -> u32

局部原子下标 → 全局下标。不做越界检查。

Source

pub fn local_atom(&self, global: u32) -> Option<u32>

全局原子下标 → 局部下标。不属于本分子时返回 None

Source

pub fn atom(&self, local: u32) -> Option<AtomData>

取原子。越界返回 None

Source

pub fn bond(&self, local: u32) -> Option<BondData>

取键,端点为局部下标。越界返回 None

Source

pub fn degree(&self, local: u32) -> usize

原子的度(不含隐式氢)

Source

pub fn neighbors(&self, local: u32) -> impl Iterator<Item = (u32, u32)> + 'a

遍历某原子的邻居,产出 (邻居局部下标, 键局部下标)

顺序即键的插入顺序 —— 手性语义依赖于此,详见 batch 模块中 CSR 构建的说明。

Source

pub fn atoms(&self) -> impl Iterator<Item = (u32, AtomData)> + '_

遍历全部原子,产出 (局部下标, 原子)

Source

pub fn bonds(&self) -> impl Iterator<Item = (u32, BondData)> + '_

遍历全部键,产出 (局部下标, 键)

Source

pub fn to_builder(&self) -> MolBuilder

拷贝回可变的 MolBuilder,用于编辑或反应产物构建。

这是 MolBatchBuilder::push 的逆操作;二者的往返恒等性由测试保证。

Trait Implementations§

Source§

impl<'a> Clone for MolView<'a>

Source§

fn clone(&self) -> MolView<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for MolView<'a>

Source§

impl<'a> Debug for MolView<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for MolView<'a>

§

impl<'a> RefUnwindSafe for MolView<'a>

§

impl<'a> Send for MolView<'a>

§

impl<'a> Sync for MolView<'a>

§

impl<'a> Unpin for MolView<'a>

§

impl<'a> UnsafeUnpin for MolView<'a>

§

impl<'a> UnwindSafe for MolView<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.