Add Immutable*Array.reverse()
See original GitHub issueImmutableIntArray
and its counterparts are a nice abstraction over primitive arrays that do not only offer the benefit of immutability, but also provide the nice ability to create a sub-array view without copying it, which is not possible with primitive arrays.
In a similar manner it would be nice if these classes would provide a reverse()
method that returns a reversed view.
Precedent for this is ImmutableList.reverse()
.
My use case is existing code that uses ImmutableIntArray
where I want to optionally allow reversing the order of iterations. Currently this needs to be done by dumping the ImmutableIntArray
into an array, call Ints.reverse()
, and reconstruct an ImmutableIntArray
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
rust - Reverse order of a reference to immutable array slice
reversed() seems to return () , which makes sense as it's done in-place, and I only have a referenced slice. .iter().rev() creates an...
Read more >All about Immutable Arrays and Objects in JavaScript
Immutable array operations. Push; Unshift; Pop; Shift; Removal and inserting of items; Sort and reverse. Immutable object operations.
Read more >ImmutableArray<T>.Builder.Reverse Method - Microsoft Learn
Reverses the order of elements in the collection.
Read more >Immutable Array Methods: Write Cleaner JavaScript Code
Immutable Array Methods: Let's Fix this Mutating Mess! · Pop · Push · Shift and Unshift · Reverse · Splice · Removing an...
Read more >Immutable Arrays and Objects in JavaScript, the Native Way
The push() method allows us to add a new item at the end of existing ... immutableArray].reverse() console.log(immutableArray) // Output: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure, over time, familiarity with SeqColls might lead more users to “expect” to find reversed() on these classes too. That’s going to be a very slow effect though, and at some point Valhalla’s going to enable
ImmutableList<int>
and make this whole class obsolete.At this point I think it’s fair to say that the case is not “clearly compelling” enough. Reopen if something changes.