Make Surface Mesh Index_iterator random access

This commit is contained in:
Simon Giraudot 2018-04-09 16:34:56 +02:00
parent efca373e30
commit b894992e8d
1 changed files with 15 additions and 5 deletions

View File

@ -123,9 +123,7 @@ namespace CGAL {
/// decrement.
SM_Index operator--(int) { SM_Index tmp(*this); --idx_; return tmp; }
SM_Index operator+=(std::ptrdiff_t n) { idx_ += n; return *this; }
private:
size_type idx_;
@ -463,12 +461,12 @@ private: //------------------------------------------------------ iterator types
class Index_iterator
: public boost::iterator_facade< Index_iterator<Index_>,
Index_,
std::bidirectional_iterator_tag
std::random_access_iterator_tag
>
{
typedef boost::iterator_facade< Index_iterator<Index_>,
Index_,
std::bidirectional_iterator_tag
std::random_access_iterator_tag
> Facade;
public:
Index_iterator() : hnd_(), mesh_(NULL) {}
@ -497,6 +495,18 @@ private: //------------------------------------------------------ iterator types
while ( mesh_->has_valid_index(hnd_) && mesh_->is_removed(hnd_)) --hnd_;
}
void advance(std::ptrdiff_t n)
{
CGAL_assertion(mesh_ != NULL);
CGAL_assertion(!(mesh_->has_garbage()));
hnd_ += n;
}
std::ptrdiff_t distance_to(const Index_iterator& other) const
{
return std::ptrdiff_t(other.hnd_) - std::ptrdiff_t(this->hnd_);
}
bool equal(const Index_iterator& other) const
{
return this->hnd_ == other.hnd_;