Mercurial > hg > octave-kai
changeset 9511:cc1fd3084cb2
implement dim_vector::first_non_singleton
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 10 Aug 2009 14:20:48 +0200 |
parents | 1b290ce305fb |
children | 56e850e3b06f |
files | liboctave/ChangeLog liboctave/dim-vector.h |
diffstat | 2 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,7 @@ +2009-08-10 Jaroslav Hajek <highegg@gmail.com> + + * dim-vector.h (dim_vector::first_non_singleton): New method. + 2009-08-06 Jaroslav Hajek <highegg@gmail.com> * dim-vector.h (dim_vector): Rewrite. Use single-alloc implementation
--- a/liboctave/dim-vector.h +++ b/liboctave/dim-vector.h @@ -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