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

Implement permutation view for external sort. #4920

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

lums658
Copy link
Contributor

@lums658 lums658 commented Apr 29, 2024

This pull request implements the permutation_view class. A permutation_view provides a view over an underlying range that is permuted by indirecting with a given index range. It is required that the permutation range is the same size as the data range and that it contain the values 0, 1, ..., N-1, in arbitrary order, where N is the size of the data range.

Example:

  std::vector<int> v{1, 2, 3, 4, 5};
  std::vector<size_t> p{4, 3, 2, 1, 0};
  permutation_view view(v, p);

  CHECK(std::ranges::equal(view, std::vector<int>{5, 4, 3, 2, 1}));

The implementation uses iterator_facade to realize a C++20 standards conformant iterator and so that permutation_view satisfies the appropriate C++20 ranges concepts.

The permutation_view class has been tested with var_length_view. Various range and iterator concepts are also tested.

(This PR also cleans up the documentation and the structure of the var_length_view class.)

[sc-43635]


TYPE: IMPROVEMENT
DESC: Implement permutation view for external sort.

This pull request implements the `permutation_view` class.  A `permutation_view` provides a view over an underlying range that is permuted by indirecting with a given index range.  It is required that the permutation range is the same size as the data range and that it  contain the values 0, 1, ..., N-1, in arbitrary order, where N is the size of the data range.

Example:
```c++
  std::vector<int> v{1, 2, 3, 4, 5};
  std::vector<size_t> p{4, 3, 2, 1, 0};
  permutation_view view(v, p);

  CHECK(std::ranges::equal(view, std::vector<int>{5, 4, 3, 2, 1}));
```

The implementation uses `iterator_facade` to realize a C++20 standards conformant iterator and so that `permutation_view` satisfies the appropriate C++20 ranges concepts.

The `permutation_view` class has been tested with `var_length_view`.  Various range and iterator concepts are also tested.

(This PR also cleans up the documentation and the structure of the `var_length_view` class.)

---
TYPE: IMPROVEMENT
DESC: Implement permutation view for external sort.
@KiterLuc KiterLuc force-pushed the al/permutation-view/ch43635 branch from 8c70fd5 to fa882e0 Compare April 29, 2024 20:43
@KiterLuc KiterLuc merged commit 910b844 into dev Apr 29, 2024
58 checks passed
@KiterLuc KiterLuc deleted the al/permutation-view/ch43635 branch April 29, 2024 22:11
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.

2 participants