#pragma once #include #include #include #include #include #include namespace sequence { struct Record { std::int64_t key; std::int64_t payload; std::int64_t ticket; }; struct Reply { int code; std::vector values; }; struct State { std::int64_t next_ticket; std::array, 3> banks; }; class Engine { public: Engine(); ~Engine(); Engine(const Engine&) = delete; Engine& operator=(const Engine&) = delete; Reply reset(std::int64_t bank); Reply append(std::int64_t bank, std::int64_t key, std::int64_t payload); Reply order(std::int64_t bank, std::int64_t descending); Reply merge(std::int64_t destination, std::int64_t left, std::int64_t right, std::int64_t descending); Reply item(std::int64_t bank, std::int64_t index) const; Reply range(std::int64_t bank, std::int64_t offset, std::int64_t count) const; Reply locate(std::int64_t bank, std::int64_t ticket) const; State inspect() const; private: struct Storage; std::unique_ptr storage_; }; int run_cli(Engine& engine, std::istream& input, std::ostream& output); }