question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Immutable*Array.reverse()

See original GitHub issue

ImmutableIntArray 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:closed
  • Created 3 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinb9ncommented, Oct 29, 2022

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.

0reactions
kevinb9ncommented, Oct 31, 2022

At this point I think it’s fair to say that the case is not “clearly compelling” enough. Reopen if something changes.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found