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

Windows of Window(Left|Right) are not isolated from each other #652

Closed
Orace opened this issue Nov 6, 2019 · 3 comments · Fixed by #655
Closed

Windows of Window(Left|Right) are not isolated from each other #652

Orace opened this issue Nov 6, 2019 · 3 comments · Fixed by #655
Assignees
Labels
Milestone

Comments

@Orace
Copy link
Contributor

Orace commented Nov 6, 2019

List returned by Window* methods should be isolated from each other.

With current implementation, modifying one window will modify the next windows accordingly:

var sequence = Enumerable.Repeat(0, 3);
foreach (var window in sequence.Window(2))
{
  window[1] = 1; // modify the last element

  // on second iteration window[0] is 1 and this fail
  Assert.That(window[0], Is.EqualTo(0));
}
This was referenced Nov 6, 2019
@atifaziz
Copy link
Member

atifaziz commented Nov 6, 2019

This is by-design. You are allowed to do what you want with the returned windows. What's important is that those windows are independent of each other as well as the original sequence from which they were created such that modifying an element through one window doesn't affect others or the source.

@atifaziz atifaziz closed this as completed Nov 6, 2019
@Orace
Copy link
Contributor Author

Orace commented Nov 6, 2019

those windows are independent of each other

@atifaziz That is exactly what I show here: windows are not independent from each others
Modifying an element through one window may affect others !

Please reopen this issue.

In F#, Each window is returned as a fresh array.

@Orace Orace changed the title Bug: Window, WindowLeft and WindowRight expose their internal buffers. Bug: Elements returned by Window* methods are not isolated from each other. Nov 6, 2019
@atifaziz
Copy link
Member

atifaziz commented Nov 6, 2019

I re-read the code and you're absolutely right. Sorry for closing this but your explanation and test in #653 didn't read clear enough. Thanks for persevering.

@atifaziz atifaziz reopened this Nov 6, 2019
@atifaziz atifaziz added the bug label Nov 6, 2019
@atifaziz atifaziz added this to the 3.3.0 milestone Nov 6, 2019
@atifaziz atifaziz changed the title Bug: Elements returned by Window* methods are not isolated from each other. Windows of Window(Left|Right) are not isolated from each other Nov 6, 2019
atifaziz pushed a commit that referenced this issue Nov 20, 2019
This is a squashed merge of PR #655 that closes #652.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants