Skip to content

[FEATURE] aglo::fill_with_pattern #2370

Description

@DenisYaroshevskiy

This is just a cool problem to solve that I want to solve at some point.

Interface

eve::algo::fill_with_pattern(R1&& output, R2&& pattern)

similar to std::fill or eve::algo::fill.

It should do an equivalent of

void fill_with_patter(std::span<T> out, std::span<const T> pattern) {
   EVE_ASSERT(!pattern.empty());   
   auto out_it = out.begin();
   
   while(true) {
      for (const auto& x : pattern) {
          if (out_it == out.end()) return;
          *out_it++ = x;
      }
   }
}

This is a surprisingly cute problem to do efficiently for small patterns.
And needs at least some thinking for bigger patterns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    low-prioLow priority item

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions