Skip to main content

RangeSetND

Struct RangeSetND 

Source
pub struct RangeSetND {
    pub vecrangesets: Vec<Vec<RangeSet>>,
    /* private fields */
}
Expand description

N-dimensional range set, used internally by NodeSet for multi-range patterns.

NOTE: unlike Python’s RangeSetND, no automatic n-dimensional folding (merging/sorting of overlapping vectors, i.e. precond_fold) is performed yet. Iteration and RangeSetND::index follow the stored vector order, so callers wanting Python-identical positions must store vectors already disjoint, merged, and ordered the way Python’s fold would leave them.

Fields§

§vecrangesets: Vec<Vec<RangeSet>>

Implementations§

Source§

impl RangeSetND

Source

pub fn new(autostep: Option<u32>) -> Self

Source

pub fn from_rangesets( vecrangesets: Vec<Vec<RangeSet>>, autostep: Option<u32>, ) -> Self

Build from a vector of RangeSet vectors, mirroring Python’s RangeSetND([[rs1, rs2, ...], ...]).

Source

pub fn len(&self) -> usize

Count elements as the sum of each vector’s Cartesian-product size.

Without nD folding this counts duplicate index vectors across overlapping stored vectors multiple times; Python’s __len__ folds first and counts unique vectors only.

Source

pub fn is_empty(&self) -> bool

Whether the set contains no element.

Source

pub fn iter(&self) -> impl Iterator<Item = Vec<String>> + '_

Iterate over all index vectors (as zero-padded strings) in iteration order: stored vectors in order, and within each vector the Cartesian product of its sorted RangeSets with the last dimension varying fastest (Python’s RangeSetND._iter()).

Source

pub fn index<T: ToString>(&self, elem: &[T]) -> Option<usize>

Return the zero-based position of an index vector in iteration order, or None if absent (Python raises ValueError).

Ports Python’s RangeSetND.index() (ClusterShell commit 484d230), the reverse operation of RangeSetND.__getitem__. Elements may be strings (zero-padding is then significant) or integers; anything ToString covers mirrors Python’s "%s" % e conversion. Python’s TypeError for bare strings/scalars is a compile-time impossibility here since a slice of indexes is required.

Source

pub fn index_within<T: ToString>( &self, elem: &[T], start: isize, stop: Option<isize>, ) -> Option<usize>

RangeSetND::index restricted to a search window, mirroring Python’s optional start/stop arguments (list.index() semantics; negative bounds count from the end).

Trait Implementations§

Source§

impl Clone for RangeSetND

Source§

fn clone(&self) -> Self

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 Debug for RangeSetND

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, !>

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.