-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add slice method to array #287
base: main
Are you sure you want to change the base?
Conversation
5458b81
to
e283b91
Compare
@@ -48,6 +49,13 @@ namespace sparrow | |||
return array_element(*p_array, index); | |||
} | |||
|
|||
void array::slice(size_type start, size_type end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer slice to return a array which is a view to the original array.
ie auto sliced_arr = arr.slice(start, end);
With the view function of the arrow_proxy it should be possible to create a cheap "view-copy" of the array and than change the offset and size there
Or maybe we should be explicit
auto sliced_arr = arr.slice(start, end); #deep copy
auto sliced_arr = arr.slice_view(start, end); #view
arr.slice_inplace(start, end) #modify
(not sure if the last one is needed or a good idea as mutating an array should be avoided if possible,imho)
ar.slice(2, 8); | ||
|
||
REQUIRE_EQ(ar.size(), 6); | ||
CHECK_EQ(std::get<const_reference>(ar[0]), make_nullable<scalar_value_type>(2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add this to the consistency test instead of implementing this by hand
No description provided.