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

Copy-avoidance optimizations on Combinatorics #981

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

Conversation

Silver-Fang
Copy link
Contributor

@Silver-Fang Silver-Fang commented Jan 19, 2023

Support [ReadOnly]Span, because unlike arrays, it cannot be cast to IEnumerable without an extra copy. Memory has a Span property that does not copy so no need to add a version for it. Note that Span only support .Net Core 2.1 and later versions on this line. Framework, Standard (except the rarely used Standard 2.1) and UWP don't support Span.

Extend arrays to I[ReadOnly]List. For arrays this interface behaves identically, but it can also support other implementations without an extra copy. For example, SelectPermutationInplace could only perform on the full range of an array - it was not possible to permute only a segment of the array. Now you can create an ArraySegment, which implements IList, and pass it to SelectPermutationInplace. Only the range specified when creating the ArraySegment will be permuted. You can also pass ArraySegment to other similar functions. This is more efficient than Skip-Take in that it does not copy.

Add an InPlace version of SelectVariation to save a copy if the caller allows modifications on the input data.

Support [ReadOnly]Span, because unlike arrays, it cannot be cast to IEnumerable without an extra copy.
Extend arrays to I[ReadOnly]List. For arrays this interface behaves identically, but it can also support other implementations without an extra copy.
Add an InPlace version of SelectVariation to save a copy if the caller allows modifications on the input data.
@Silver-Fang Silver-Fang changed the title Copy-avoidance optimizations Copy-avoidance optimizations on Combinatorics Jan 19, 2023
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.

None yet

1 participant