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

Add permutations and permutations_sized adaptors #230

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
laid out basics of permutation adaptor, still researching impl strate…
…gies
  • Loading branch information
nwad123 committed Nov 27, 2024
commit 94fa017c01a00a4fb5bebb83814ba3ad00e0a1c2
48 changes: 48 additions & 0 deletions include/flux/adaptor/permutations.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

// Copyright stuff here? Not really sure on that as I've never done
// it

#ifndef FLUX_ADAPTOR_PERMUTATIONS_HPP_INCLUDED
#define FLUX_ADAPTOR_PERMUTATIONS_HPP_INCLUDED

#include "flux/core/concepts.hpp"
#include "flux/core/inline_sequence_base.hpp"
#include "flux/macros.hpp"
#include <cstddef>
#include <flux/core.hpp>

namespace flux {

namespace detail {

template <flux::sequence Base, std::size_t Length>
requires(Length > 0) && flux::bounded_sequence<Base> // permutation of size 0 don't make sense and infinite sequences don't make sense either
struct permutations_adaptor : inline_sequence_base<permutations_adaptor<Base, Length>> {
private:
Base base_;
inline static constexpr std::size_t length_ = Length;

public:
constexpr permutations_adaptor(Base&& base) : base_(FLUX_FWD(base)) { }

struct flux_sequence_traits : default_sequence_traits {
private:
using self_t = permutations_adaptor;
using element_t = std::vector<flux::value_t<Base>>;

struct cursor_type {
/* final type is todo */ std::vector<flux::value_t<Base>> vals_;
/* final type is todo */ std::vector<flux::cursor_t<Base>> indices;
/* final type is todo */ std::vector<flux::cursor_t<Base>> cycles;

constexpr bool operator==(cursor_type const&) const = default;
};

public:
using value_type = std::vector<flux::value_t<Base>>;
};
};
} // namespace detail

} // namespace flux
#endif