Update iterators: mark null_dart to use it as sentinel.

This commit is contained in:
Guillaume Damiand 2012-11-22 19:12:55 +01:00
parent 5ac344ec48
commit 3d0d6817e0
2 changed files with 29 additions and 6 deletions

View File

@ -477,7 +477,7 @@ namespace CGAL {
void set_mark_to(Dart_const_handle adart, int amark,
bool astate) const
{
// CGAL_assertion( adart != null_dart_handle );
CGAL_assertion( adart != null_dart_handle );
CGAL_assertion( is_reserved(amark) );
if (is_marked(adart, amark) != astate)
@ -495,7 +495,7 @@ namespace CGAL {
*/
void mark(Dart_const_handle adart, int amark) const
{
// CGAL_assertion( adart != null_dart_handle );
CGAL_assertion( adart != null_dart_handle );
CGAL_assertion( is_reserved(amark) );
if (is_marked(adart, amark)) return;
@ -510,7 +510,7 @@ namespace CGAL {
*/
void unmark(Dart_const_handle adart, int amark) const
{
// CGAL_assertion( adart != null_dart_handle );
CGAL_assertion( adart != null_dart_handle );
CGAL_assertion( is_reserved(amark) );
if (!is_marked(adart, amark)) return;
@ -519,6 +519,28 @@ namespace CGAL {
adart->set_mark(amark, mmask_marks[(size_type)amark]);
}
/** Mark null_dart (used as a sentinel in iterators).
* As null dart does not belong to the set of darts, it is not counted
* as number of marked darts.
* @param amark the given mark.
*/
void mark_null_dart(int amark) const
{
CGAL_assertion( is_reserved(amark) );
null_dart_handle->set_mark(amark, !mmask_marks[(size_type)amark]);
}
/** Unmark null_dart.
* @param amark the given mark.
*/
void unmark_null_dart(int amark) const
{
CGAL_assertion( is_reserved(amark) );
null_dart_handle->set_mark(amark, mmask_marks[(size_type)amark]);
}
/** Unmark all the darts of the map for a given mark.
* If all the darts are marked or unmarked, this operation takes O(1)
* operations, otherwise it traverses all the darts of the map.
@ -536,7 +558,7 @@ namespace CGAL {
}
else
{
unmark(null_dart_handle, amark);
unmark_null_dart(amark);
for (typename Dart_range::const_iterator it(darts().begin()),
itend(darts().end()); it!=itend; ++it)
unmark(it, amark);
@ -1906,6 +1928,7 @@ namespace CGAL {
}
for (unsigned int i=0; i<tounmark.size(); ++i)
{
unmark(null_dart_handle, tounmark[i]);
CGAL_assertion(is_whole_map_unmarked(tounmark[i]));
free_mark(tounmark[i]);
}

View File

@ -187,7 +187,7 @@ namespace CGAL {
{
if ( minitial_dart!=NULL )
{
this->mmap->mark(this->mmap->null_dart_handle, mmark_number);
this->mmap->mark_null_dart(mmark_number);
this->mmap->mark(minitial_dart, mmark_number);
if (!minitial_dart->is_free(Bi) && minitial_dart->beta(Bi)!=minitial_dart )
{
@ -204,7 +204,7 @@ namespace CGAL {
Base::operator= ( Base(*this->mmap,minitial_dart) );
mto_treat = std::queue<Dart_handle>();
this->mmap->mark(minitial_dart, mmark_number);
this->mmap->mark(this->mmap->null_dart_handle, mmark_number);
this->mmap->mark_null_dart(mmark_number);
if (!minitial_dart->is_free(Bi) && minitial_dart->beta(Bi)!=minitial_dart )
{
mto_treat.push(minitial_dart->beta(Bi));