-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
A function to resize vectors in front? #26326
Comments
We do have |
That would also allow providing Though rather than |
@mbauman : Right - but to "append!", you first need an array to append, you can't create uninitialized space that way. And Also, there's currently no way to shorten the array in front - except for |
I thought about that, initially - but then |
|
|
|
But splice just removes a single element (in an arbitrary location) right? |
True - then maybe |
You can pass a range to |
Thanks, @JeffBezanson , I should have read the help of |
@mbauman, thanks for pointing out that we have |
AFAIK we're currently lacking a function to resize a vector in front (well, except for the internals like
Base._growbeg!
).push!
,pop!
andresize!
.pushfirst!
andpopfirst!
.This is lacking in symmetry. :-) Could we add
Base.resizefirst!
?Symmetry aside, it may also come in quite handy in some applications - I ran into this when I wanted to implement resizing in front for
ElasticArray
(some use cases will need it): I really don't want to useccall(:jl_array_grow_beg, ...)
, if avoidable, and there's no generic name in Base to overload for the resulting function. Or maybe I just missed it?The text was updated successfully, but these errors were encountered: