You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.7 KiB
52 lines
1.7 KiB
#pragma once
|
|
|
|
#include "container/stl_alias.hpp"
|
|
#include "iterator/counting_iterator.hpp"
|
|
|
|
struct flat_index_group {
|
|
stl_vector_mp<uint32_t> index_group{}; /// a list of indices in the group
|
|
stl_vector_mp<uint32_t> start_indices{}; /// a list of start indices for each group in the flat index group
|
|
|
|
inline size_t size() const { return start_indices.size() - 1; }
|
|
|
|
struct group_index_looper {
|
|
auto begin() const { return counting_iterator<uint32_t>{0}; }
|
|
|
|
auto end() const { return counting_iterator<uint32_t>{static_cast<uint32_t>(parent_group.size())}; }
|
|
|
|
const flat_index_group& parent_group{};
|
|
};
|
|
|
|
auto group_indices() const { return group_index_looper{*this}; }
|
|
|
|
struct group_looper {
|
|
auto begin() const
|
|
{
|
|
return std::next(parent_group.index_group.begin(), *(parent_group.start_indices.begin() + group_idx));
|
|
}
|
|
|
|
auto end() const
|
|
{
|
|
return std::next(parent_group.index_group.begin(), *(parent_group.start_indices.begin() + group_idx + 1));
|
|
}
|
|
|
|
const flat_index_group& parent_group{};
|
|
const uint32_t group_idx{};
|
|
};
|
|
|
|
auto group(uint32_t group_idx) const { return group_looper{*this, group_idx}; }
|
|
|
|
inline auto group_index_iter_begin() const { return counting_iterator<uint32_t>{0}; }
|
|
|
|
inline auto group_index_iter_end() const { return counting_iterator<uint32_t>{static_cast<uint32_t>(size())}; }
|
|
|
|
inline auto group_begin(uint32_t group_idx) const
|
|
{
|
|
return std::next(index_group.begin(), *(start_indices.begin() + group_idx));
|
|
}
|
|
|
|
inline auto group_end(uint32_t group_idx) const
|
|
{
|
|
return std::next(index_group.begin(), *(start_indices.begin() + group_idx + 1));
|
|
}
|
|
};
|