diff options
Diffstat (limited to 'gfx/gl')
-rw-r--r-- | gfx/gl/instanceVertices.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gfx/gl/instanceVertices.h b/gfx/gl/instanceVertices.h index d9d9123..ad1716d 100644 --- a/gfx/gl/instanceVertices.h +++ b/gfx/gl/instanceVertices.h @@ -124,6 +124,13 @@ public: return base::size(); } + template<typename Pred> + glContainer<T>::iterator + partition(Pred pred) + { + return partition(base::begin(), base::end(), pred); + } + protected: friend InstanceProxy; @@ -152,6 +159,22 @@ protected: return base::data()[index[pindex]]; } + template<typename Pred> + glContainer<T>::iterator + partition(glContainer<T>::iterator first, glContainer<T>::iterator last, Pred pred) + { + while (first < last) { + first = std::find_if_not(first, last, pred); + last = --std::find_if(std::make_reverse_iterator(last), std::make_reverse_iterator(first), pred).base(); + if (first < last) { + std::iter_swap(first, last); + std::iter_swap(std::find(index.begin(), index.end(), first - base::begin()), + std::find(index.begin(), index.end(), last - base::begin())); + } + } + return first; + } + // Index into buffer given to nth proxy std::vector<size_t> index; // List of free spaces in index |