getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] r5008 - /trunk/getfem/src/getfem/dal_bit_vector.h


From: andriy . andreykiv
Subject: [Getfem-commits] r5008 - /trunk/getfem/src/getfem/dal_bit_vector.h
Date: Wed, 27 May 2015 14:45:52 -0000

Author: andrico
Date: Wed May 27 16:45:51 2015
New Revision: 5008

URL: http://svn.gna.org/viewcvs/getfem?rev=5008&view=rev
Log: (empty)

Modified:
    trunk/getfem/src/getfem/dal_bit_vector.h

Modified: trunk/getfem/src/getfem/dal_bit_vector.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/dal_bit_vector.h?rev=5008&r1=5007&r2=5008&view=diff
==============================================================================
--- trunk/getfem/src/getfem/dal_bit_vector.h    (original)
+++ trunk/getfem/src/getfem/dal_bit_vector.h    Wed May 27 16:45:51 2015
@@ -400,11 +400,18 @@
     //difference of iterators
     size_type operator-(const const_bv_iterator &other) const{
       if (pos_ == other.pos_) return 0;
-      auto it  = (pos_ < other.pos_) ? *this : other;
-      auto end = (pos_ > other.pos_) ? *this : other;
-      size_type size = 0;
-      while(it.pos_ < end.pos_) { it++; size++;}
-      return size;
+
+      auto &vector_this  = p_iterable_->v_;
+      auto &vector_other = other.p_iterable_->v_;
+      bv_visitor v_this(vector_this), v_other(vector_other);
+      while (v_this < pos_) ++v_this;
+      while (v_other < other.pos_) ++v_other;
+      auto &v     = (pos_ < other.pos_)  ? v_this : v_other;
+      auto &v_end = (pos_ >= other.pos_) ? v_this : v_other;
+
+      size_type count = 0;
+      while(v < v_end) { ++v; ++count;}
+      return count;
     }
 
     const const_bv_iterator &operator++(){
@@ -441,6 +448,7 @@
   private:
     const bit_vector& v_;
     bv_visitor visitor_;
+    friend class const_bv_iterator<bv_iterable>;
   };
 
   /***Same as bv_iterable class except the bit_vector is copied locally.*/
@@ -456,6 +464,7 @@
   private:
     bit_vector v_;
     bv_visitor visitor_;
+    friend class const_bv_iterator<bv_iterable_c>;
   };
 
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]