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
impl RangeSetND
pub fn new(autostep: Option<u32>) -> Self
Sourcepub fn from_rangesets(
vecrangesets: Vec<Vec<RangeSet>>,
autostep: Option<u32>,
) -> Self
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, ...], ...]).
Sourcepub fn len(&self) -> usize
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.
Sourcepub fn iter(&self) -> impl Iterator<Item = Vec<String>> + '_
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()).
Sourcepub fn index<T: ToString>(&self, elem: &[T]) -> Option<usize>
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.
Sourcepub fn index_within<T: ToString>(
&self,
elem: &[T],
start: isize,
stop: Option<isize>,
) -> Option<usize>
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).