mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-20 12:20:01 +00:00
Enhance column access methods to clarify usage by name and physical index
This commit is contained in:
parent
349ae52629
commit
49f7558225
@ -309,7 +309,7 @@ impl<T: Clone + PartialEq> Frame<T> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an immutable slice of the specified column's data.
|
/// Returns an immutable slice of the specified column's data by name.
|
||||||
/// Panics if the column name is not found.
|
/// Panics if the column name is not found.
|
||||||
pub fn column(&self, name: &str) -> &[T] {
|
pub fn column(&self, name: &str) -> &[T] {
|
||||||
let idx = self
|
let idx = self
|
||||||
@ -318,7 +318,13 @@ impl<T: Clone + PartialEq> Frame<T> {
|
|||||||
self.matrix.column(idx)
|
self.matrix.column(idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a mutable slice of the specified column's data.
|
/// Returns an immutable slice of the specified column's data by its physical index.
|
||||||
|
/// Panics if the index is out of bounds.
|
||||||
|
pub fn column_by_physical_idx(&self, idx: usize) -> &[T] {
|
||||||
|
self.matrix.column(idx)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a mutable slice of the specified column's data by name.
|
||||||
/// Panics if the column name is not found.
|
/// Panics if the column name is not found.
|
||||||
pub fn column_mut(&mut self, name: &str) -> &mut [T] {
|
pub fn column_mut(&mut self, name: &str) -> &mut [T] {
|
||||||
let idx = self
|
let idx = self
|
||||||
@ -327,6 +333,12 @@ impl<T: Clone + PartialEq> Frame<T> {
|
|||||||
self.matrix.column_mut(idx)
|
self.matrix.column_mut(idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a mutable slice of the specified column's data by its physical index.
|
||||||
|
/// Panics if the index is out of bounds.
|
||||||
|
pub fn column_mut_by_physical_idx(&mut self, idx: usize) -> &mut [T] {
|
||||||
|
self.matrix.column_mut(idx)
|
||||||
|
}
|
||||||
|
|
||||||
// Row access methods
|
// Row access methods
|
||||||
|
|
||||||
/// Returns an immutable view of the row for the given integer key.
|
/// Returns an immutable view of the row for the given integer key.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user