#include "container.hpp" #include #include #include namespace ae { container::container(std::span data) { // Reserve enough space for the chunks to avoid relocation while building the structure container::Directory dir(data.size() / container::chunk_size + 1); auto entry = 0; for (auto first = data.begin(); first < data.end();) { const auto last = (data.end() - first) < container::chunk_size ? data.end() : first + container::chunk_size; Chunk chunk; // This could be improved by just pointing dir[entry] to first, removing the copy process. std::copy(first, last, chunk.begin()); dir[entry++] = chunk; first = last; } this->data = dir; this->size_ = data.size(); } uint32_t container::size() { return this->size_; } } // namespace ae