diff liboctave/dim-vector.h @ 9511:cc1fd3084cb2

implement dim_vector::first_non_singleton
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 10 Aug 2009 14:20:48 +0200
parents b096d11237be
children 11844593875a
line wrap: on
line diff
--- a/liboctave/dim-vector.h	Mon Aug 10 11:35:59 2009 +0200
+++ b/liboctave/dim-vector.h	Mon Aug 10 14:20:48 2009 +0200
@@ -497,6 +497,17 @@
       return (length () == 2 && (elem (0) == 1 || elem (1) == 1));
     }
 
+  int first_non_singleton (int def = 0) const
+    {
+      for (int i = 0; i < length (); i++)
+        {
+          if (elem (i) != 1)
+            return i;
+        }
+
+      return def;      
+    }
+
 };
 
 static inline bool