pub enum AtomSelection {
Empty,
All(u32),
Range(Range<u32>),
Ranges(SmallVec<[Range<u32>; 4]>),
Sparse(Vec<u32>),
Dense(BitVec),
}Expand description
A set of atoms, addressed by position in the structure’s flat atom order.
§Examples
use molframe_core::AtomSelection;
let chain = AtomSelection::range(0..100);
let metals = AtomSelection::from_sorted(vec![5, 50, 500]);
assert_eq!(chain.intersect(&metals).len(), 2);Variants§
Empty
No atoms.
All(u32)
Every atom of a structure with this many.
Range(Range<u32>)
One contiguous run.
Ranges(SmallVec<[Range<u32>; 4]>)
Several contiguous runs, ascending and disjoint.
Sparse(Vec<u32>)
Scattered positions, ascending and unique.
Dense(BitVec)
A bit per position, for a set dense enough to make that cheaper.
Implementations§
Source§impl AtomSelection
impl AtomSelection
Sourcepub fn difference(&self, other: &Self) -> Self
pub fn difference(&self, other: &Self) -> Self
The atoms in this selection but not the other.
Sourcepub fn complement(&self, count: u32) -> Self
pub fn complement(&self, count: u32) -> Self
Every atom of a structure of count atoms that this selection excludes.
Sourcepub fn heap_bytes(&self) -> usize
pub fn heap_bytes(&self) -> usize
The bytes this selection occupies beyond its own header.
Source§impl AtomSelection
impl AtomSelection
Sourcepub fn from_sorted(positions: Vec<u32>) -> Self
pub fn from_sorted(positions: Vec<u32>) -> Self
Chooses the cheapest shape for ascending unique positions.
§Panics
Panics if positions is not ascending and unique, or if its storage
exceeds the platform’s addressable range. Collect arbitrary positions
into AtomSelection to sort and deduplicate them first.
Sourcepub fn len(&self) -> u64
pub fn len(&self) -> u64
The number of atoms selected.
§Panics
Panics if manually constructed storage violates normalized u32 ranges.
Sourcepub fn position_bound(&self) -> u32
pub fn position_bound(&self) -> u32
One past the largest position this selection could name.
Derived from the shape rather than the positions, so a whole-structure
selection answers from its own count and a run from its end. A caller
that has to prove every position is inside a structure compares this once
instead of asking about each atom — which matters because the cheapest
selections, All and Empty, are exactly the ones a per-atom walk would
read as a full traversal of the structure.
The bound is exact: no position in the selection reaches it, and every shape reports the smallest bound that says so.
Sourcepub fn iter(&self) -> SelectionIter<'_> ⓘ
pub fn iter(&self) -> SelectionIter<'_> ⓘ
The selected positions, ascending.
A concrete iterator rather than a boxed one: the boxed form cost a heap allocation per call and a virtual call per position, which prevented the consuming loop from inlining anything. Selection walks are the innermost loop of every spatial and analysis pass.
Trait Implementations§
Source§impl Clone for AtomSelection
impl Clone for AtomSelection
Source§impl Debug for AtomSelection
impl Debug for AtomSelection
Source§impl Default for AtomSelection
impl Default for AtomSelection
impl Eq for AtomSelection
Source§impl FromIterator<u32> for AtomSelection
impl FromIterator<u32> for AtomSelection
Source§impl<'a> IntoIterator for &'a AtomSelection
impl<'a> IntoIterator for &'a AtomSelection
Source§impl PartialEq for AtomSelection
impl PartialEq for AtomSelection
impl StructuralPartialEq for AtomSelection
Auto Trait Implementations§
impl Freeze for AtomSelection
impl RefUnwindSafe for AtomSelection
impl Send for AtomSelection
impl Sync for AtomSelection
impl Unpin for AtomSelection
impl UnsafeUnpin for AtomSelection
impl UnwindSafe for AtomSelection
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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