Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Row and column slice getter #55

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ibarrond
Copy link

@ibarrond ibarrond commented Aug 22, 2024

Adds get_row and get_col functions to access the corresponding underlying slice of a selected row/column, returning None if out of bounds or if the values are not contiguous (e.g., a row from a grid in Order::ColumnMajor or a column from a grid in Order::RowMajor).

Equivalent mutable methods get_mut_row and get_mut_col.

EXTRA: some quick linter fixes.

@ibarrond ibarrond changed the title Row and column getter Row and column slice getter Aug 22, 2024
@ibarrond
Copy link
Author

@becheran Any chance this can be merged sometime soon?

@becheran becheran self-assigned this Aug 31, 2024
Copy link
Owner

@becheran becheran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all thanks for openening a PR.

I don't understand why those additional function whould make the library more useful? Especially because all function only work properly in one of the two modes.

let start = row_usize * self.cols;
Some(self.data[start..(start self.cols)].as_ref())
} else {
None
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look at the changes. Thanks for the formatting. I better setup my auto-formatter better.

I wonder if the implementaiton helps or is more confusing. I don't think it is a good idea to expose a function called get_row which only works in RowMajor mode.

Why not use the already existing iter_row funciton instead and let the caller decide if collecting the result into a Vec is desired?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants