pkg: Install as libstick-${PACKAGE_VERSION}.pc
[libstick.git] / include / libstick-0.1 / booleanvector.h
index 5bfd7e3391c49d44db5a5a4dda763062d3811d95..5d8706320766ea74b970bf10ae28373c4ba31814 100644 (file)
@@ -47,6 +47,11 @@ class sorted_boolean_vector {
             return array;
         }
 
+        /** Count the number of 1s. */
+        size_t size() const {
+            return get_ones().size();
+        }
+
         /** Two vectors are equal if they contain the same indices. */
         bool operator==(const sorted_boolean_vector<IT> &vec) const {
             return get_ones() == vec.get_ones();
@@ -173,6 +178,11 @@ class heapsorted_boolean_vector {
             return array;
         }
 
+        /** Count the number of 1s. */
+        size_t size() const {
+            return get_ones().size();
+        }
+
         /** Two vectors are equal if they contain the same indices. */
         bool operator==(const heapsorted_boolean_vector<IT> &vec) const {
             return get_ones() == vec.get_ones();
@@ -241,8 +251,11 @@ class heapsorted_boolean_vector {
 
         /** Returns true if vector contains no 1. */
         bool isempty() const {
-            strip_heap();
-            return isheap ? heapsize==0 : array.size()==0;
+            if (isheap) {
+                strip_heap();
+                return heapsize == 0;
+            } else
+                return array.size() == 0;
         }
 
         /** Print this vector */