IndexPath
struct · ferroui-treedatagrid-core · v0.5.0
struct IndexPath
A path of indexes into a hierarchy: one index for a row of a flat source or a root row, one more
per level below. The empty path (IndexPath::UNSELECTED, the default) is no row.
As the reference, a path of one index is stored without an allocation (_index is the index
plus one, 0 for the empty path); longer paths share an immutable array.
Members
UNSELECTEDnewfrom_indexesfrom_iter_optencoded_indexpathfrom_encodedcountis_emptygetlastparentappendis_ancestor_ofis_parent_ofsliceto_vecitercompare
UNSELECTED
const UNSELECTED: IndexPath
The empty path.
new
fn new(index: i32) -> Self
The path of one index.
from_indexes
fn from_indexes(indexes: &[i32]) -> Self
The path of the given indexes (params int[]), stored as an array even when it has one
index or none, as the reference's constructor does.
from_iter_opt
fn from_iter_opt(indexes: Option<impl IntoIterator<Item = i32>>) -> Self
The path of the given indexes, or the empty path for None (IndexPath(IEnumerable<int>?)).
encoded_index
fn encoded_index(self: &Self) -> i32
The encoded index (the index plus one; 0 for a path that is an array or empty), shared with the presentation so that virtualization does not allocate paths.
path
fn path(self: &Self) -> Option<&Rc<[i32]>>
The array of a path of more than one index (or of a path built from an array).
from_encoded
fn from_encoded(encoded_index: i32, path: Option<Rc<[i32]>>) -> Self
A path from its encoded parts (encoded_index, path).
count
fn count(self: &Self) -> usize
The number of indexes.
is_empty
fn is_empty(self: &Self) -> bool
Whether the path is empty (no row).
get
fn get(self: &Self, index: usize) -> i32
The index at index.
Panics
When index is not below count (IndexOutOfRangeException).
last
fn last(self: &Self) -> i32
The last index (index[^1]).
Panics
For the empty path.
parent
fn parent(self: &Self) -> IndexPath
The path without its last index (index[..^1]); the empty path for a path of one index.
Panics
For the empty path.
append
fn append(self: &Self, child_index: i32) -> IndexPath
The path with child_index appended.
Panics
When child_index is negative (ArgumentException).
is_ancestor_of
fn is_ancestor_of(self: &Self, other: &IndexPath) -> bool
Whether this path is an ancestor of other: a shorter prefix of it.
is_parent_of
fn is_parent_of(self: &Self, other: &IndexPath) -> bool
Whether this path is the parent of other: its prefix one shorter.
slice
fn slice(self: &Self, start: usize, length: usize) -> IndexPath
The length indexes from start.
Panics
When the range is not within the path (IndexOutOfRangeException).
to_vec
fn to_vec(self: &Self) -> Vec<i32>
The indexes as a vector.
iter
fn iter(self: &Self) -> impl Iterator<Item = i32> + '_
The indexes.
compare
fn compare(self: &Self, other: &IndexPath) -> Ordering
CompareTo: by index, a prefix before the longer path; an empty path before a non-empty
one.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeTreeModelBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringResourceKeyObjectPropertyValueAnyValueClassDefaultsErasedDestructorIntoEitherCloneDefaultFrom<i32>PartialEqEqPartialOrdOrdHashDisplayDebugIReadOnlyList<IndexPath>
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.