# HG changeset patch # User Rik # Date 1497383022 25200 # Node ID 0549061d35b9c0cb99e779d2f500697cabf38ead # Parent 0c468af9dc0009cc2324fcb3d941c5cff0ed893a maint: Deprecate is_sorted and replace with issorted. * ov.h (is_sorted): Use OCTAVE_DEPRECATED macro around function. * ov.h (issorted): New function. * Array.h (is_sorted): Use OCTAVE_DEPRECATED macro around function. * Array.h (issorted): New function. * Range.h (is_sorted): Use OCTAVE_DEPRECATED macro around function. * Range.h (issorted): New function. * oct-sort.h (is_sorted): Use OCTAVE_DEPRECATED macro around function. * oct-sort.h (issorted): New function. * data.cc, __ode15__.cc, ov-base-diag.h, ov-base-mat.h, ov-base-scalar.h, ov-base-sparse.h, ov-base.cc, ov-base.h, ov-cell.cc, ov-cell.h, ov-lazy-idx.cc, ov-lazy-idx.h, ov-perm.h, ov-range.h, ov-re-mat.cc, ov-re-mat.h, Array-d.cc, Array-f.cc, Array.cc, Range.cc, oct-sort.cc: Replace instances of is_sorted with issorted. diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/corefcn/data.cc --- a/libinterp/corefcn/data.cc Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/corefcn/data.cc Tue Jun 13 12:43:42 2017 -0700 @@ -6783,7 +6783,7 @@ if (! arg.dims ().is_vector ()) error ("issorted: needs a vector"); - retval = args(0).is_sorted (smode) != UNSORTED; + retval = args(0).issorted (smode) != UNSORTED; } return retval; diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/dldfcn/__ode15__.cc --- a/libinterp/dldfcn/__ode15__.cc Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/dldfcn/__ode15__.cc Tue Jun 13 12:43:42 2017 -0700 @@ -1146,7 +1146,7 @@ if (numt < 2) error ("__ode15__: TRANGE must contain at least 2 elements"); - else if (! tspan.is_sorted () || tspan(0) == tspan(numt - 1)) + else if (! tspan.issorted () || tspan(0) == tspan(numt - 1)) error ("__ode15__: TRANGE must be strictly monotonic"); // input y0 and yp0 diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-base-diag.h --- a/libinterp/octave-value/ov-base-diag.h Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-base-diag.h Tue Jun 13 12:43:42 2017 -0700 @@ -112,8 +112,8 @@ sortmode mode = ASCENDING) const { return to_dense ().sort (sidx, dim, mode); } - sortmode is_sorted (sortmode mode = UNSORTED) const - { return to_dense ().is_sorted (mode); } + sortmode issorted (sortmode mode = UNSORTED) const + { return to_dense ().issorted (mode); } Array sort_rows_idx (sortmode mode = ASCENDING) const { return to_dense ().sort_rows_idx (mode); } diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-base-mat.h --- a/libinterp/octave-value/ov-base-mat.h Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-base-mat.h Tue Jun 13 12:43:42 2017 -0700 @@ -136,8 +136,8 @@ sortmode mode = ASCENDING) const { return octave_value (matrix.sort (sidx, dim, mode)); } - sortmode is_sorted (sortmode mode = UNSORTED) const - { return matrix.is_sorted (mode); } + sortmode issorted (sortmode mode = UNSORTED) const + { return matrix.issorted (mode); } Array sort_rows_idx (sortmode mode = ASCENDING) const { return matrix.sort_rows_idx (mode); } diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-base-scalar.h --- a/libinterp/octave-value/ov-base-scalar.h Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-base-scalar.h Tue Jun 13 12:43:42 2017 -0700 @@ -108,7 +108,7 @@ return octave_value (scalar); } - sortmode is_sorted (sortmode mode = UNSORTED) const + sortmode issorted (sortmode mode = UNSORTED) const { return mode ? mode : ASCENDING; } Array sort_rows_idx (sortmode) const diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-base-sparse.h --- a/libinterp/octave-value/ov-base-sparse.h Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-base-sparse.h Tue Jun 13 12:43:42 2017 -0700 @@ -131,8 +131,8 @@ sortmode mode = ASCENDING) const { return octave_value (matrix.sort (sidx, dim, mode)); } - sortmode is_sorted (sortmode mode = UNSORTED) const - { return full_value ().is_sorted (mode); } + sortmode issorted (sortmode mode = UNSORTED) const + { return full_value ().issorted (mode); } MatrixType matrix_type (void) const { return typ; } MatrixType matrix_type (const MatrixType& _typ) const diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-base.cc --- a/libinterp/octave-value/ov-base.cc Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-base.cc Tue Jun 13 12:43:42 2017 -0700 @@ -1032,9 +1032,9 @@ } sortmode -octave_base_value::is_sorted (sortmode) const +octave_base_value::issorted (sortmode) const { - err_wrong_type_arg ("octave_base_value::is_sorted ()", type_name ()); + err_wrong_type_arg ("octave_base_value::issorted ()", type_name ()); } Array diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-base.h --- a/libinterp/octave-value/ov-base.h Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-base.h Tue Jun 13 12:43:42 2017 -0700 @@ -675,7 +675,7 @@ octave_idx_type dim = 0, sortmode mode = ASCENDING) const; - virtual sortmode is_sorted (sortmode mode = UNSORTED) const; + virtual sortmode issorted (sortmode mode = UNSORTED) const; virtual Array sort_rows_idx (sortmode mode = ASCENDING) const; diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-cell.cc --- a/libinterp/octave-value/ov-cell.cc Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-cell.cc Tue Jun 13 12:43:42 2017 -0700 @@ -489,7 +489,7 @@ } sortmode -octave_cell::is_sorted (sortmode mode) const +octave_cell::issorted (sortmode mode) const { sortmode retval = UNSORTED; @@ -498,7 +498,7 @@ Array tmp = cellstr_value (); - retval = tmp.is_sorted (mode); + retval = tmp.issorted (mode); return retval; } diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-cell.h --- a/libinterp/octave-value/ov-cell.h Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-cell.h Tue Jun 13 12:43:42 2017 -0700 @@ -103,7 +103,7 @@ octave_value sort (Array &sidx, octave_idx_type dim = 0, sortmode mode = ASCENDING) const; - sortmode is_sorted (sortmode mode = UNSORTED) const; + sortmode issorted (sortmode mode = UNSORTED) const; Array sort_rows_idx (sortmode mode = ASCENDING) const; diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-lazy-idx.cc --- a/libinterp/octave-value/ov-lazy-idx.cc Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-lazy-idx.cc Tue Jun 13 12:43:42 2017 -0700 @@ -128,7 +128,7 @@ } sortmode -octave_lazy_index::is_sorted (sortmode mode) const +octave_lazy_index::issorted (sortmode mode) const { if (index.is_range ()) { @@ -142,7 +142,7 @@ return (mode == ASCENDING ? UNSORTED : DESCENDING); } else - return index.as_array ().is_sorted (mode); + return index.as_array ().issorted (mode); } Array diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-lazy-idx.h --- a/libinterp/octave-value/ov-lazy-idx.h Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-lazy-idx.h Tue Jun 13 12:43:42 2017 -0700 @@ -112,7 +112,7 @@ octave_value sort (Array &sidx, octave_idx_type dim = 0, sortmode mode = ASCENDING) const; - sortmode is_sorted (sortmode mode = UNSORTED) const; + sortmode issorted (sortmode mode = UNSORTED) const; Array sort_rows_idx (sortmode mode = ASCENDING) const; diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-perm.h --- a/libinterp/octave-value/ov-perm.h Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-perm.h Tue Jun 13 12:43:42 2017 -0700 @@ -95,8 +95,8 @@ sortmode mode = ASCENDING) const { return to_dense ().sort (sidx, dim, mode); } - sortmode is_sorted (sortmode mode = UNSORTED) const - { return to_dense ().is_sorted (mode); } + sortmode issorted (sortmode mode = UNSORTED) const + { return to_dense ().issorted (mode); } Array sort_rows_idx (sortmode mode = ASCENDING) const { return to_dense ().sort_rows_idx (mode); } diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-range.h --- a/libinterp/octave-value/ov-range.h Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-range.h Tue Jun 13 12:43:42 2017 -0700 @@ -146,8 +146,8 @@ sortmode mode = ASCENDING) const { return range.sort (sidx, dim, mode); } - sortmode is_sorted (sortmode mode = UNSORTED) const - { return range.is_sorted (mode); } + sortmode issorted (sortmode mode = UNSORTED) const + { return range.issorted (mode); } Array sort_rows_idx (sortmode) const { return Array (dim_vector (1, 0)); } diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-re-mat.cc --- a/libinterp/octave-value/ov-re-mat.cc Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-re-mat.cc Tue Jun 13 12:43:42 2017 -0700 @@ -385,16 +385,16 @@ } sortmode -octave_matrix::is_sorted (sortmode mode) const +octave_matrix::issorted (sortmode mode) const { if (idx_cache) { // This is a valid index matrix, so check via integers because it's // generally more efficient. - return idx_cache->as_array ().is_sorted (mode); + return idx_cache->as_array ().issorted (mode); } else - return octave_base_matrix::is_sorted (mode); + return octave_base_matrix::issorted (mode); } Array octave_matrix::sort_rows_idx (sortmode mode) const diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov-re-mat.h --- a/libinterp/octave-value/ov-re-mat.h Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov-re-mat.h Tue Jun 13 12:43:42 2017 -0700 @@ -200,7 +200,7 @@ octave_value sort (Array &sidx, octave_idx_type dim = 0, sortmode mode = ASCENDING) const; - sortmode is_sorted (sortmode mode = UNSORTED) const; + sortmode issorted (sortmode mode = UNSORTED) const; Array sort_rows_idx (sortmode mode = ASCENDING) const; diff -r 0c468af9dc00 -r 0549061d35b9 libinterp/octave-value/ov.h --- a/libinterp/octave-value/ov.h Tue Jun 13 11:25:31 2017 -0700 +++ b/libinterp/octave-value/ov.h Tue Jun 13 12:43:42 2017 -0700 @@ -1358,8 +1358,12 @@ sortmode mode = ASCENDING) const { return rep->sort (sidx, dim, mode); } + sortmode issorted (sortmode mode = UNSORTED) const + { return rep->issorted (mode); } + + OCTAVE_DEPRECATED ("use 'issorted' instead") sortmode is_sorted (sortmode mode = UNSORTED) const - { return rep->is_sorted (mode); } + { return rep->issorted (mode); } Array sort_rows_idx (sortmode mode = ASCENDING) const { return rep->sort_rows_idx (mode); } diff -r 0c468af9dc00 -r 0549061d35b9 liboctave/array/Array-d.cc --- a/liboctave/array/Array-d.cc Tue Jun 13 11:25:31 2017 -0700 +++ b/liboctave/array/Array-d.cc Tue Jun 13 12:43:42 2017 -0700 @@ -95,7 +95,7 @@ template <> OCTAVE_API sortmode -Array::is_sorted (sortmode mode) const +Array::issorted (sortmode mode) const { octave_idx_type n = numel (); diff -r 0c468af9dc00 -r 0549061d35b9 liboctave/array/Array-f.cc --- a/liboctave/array/Array-f.cc Tue Jun 13 11:25:31 2017 -0700 +++ b/liboctave/array/Array-f.cc Tue Jun 13 12:43:42 2017 -0700 @@ -95,7 +95,7 @@ template <> OCTAVE_API sortmode -Array::is_sorted (sortmode mode) const +Array::issorted (sortmode mode) const { octave_idx_type n = numel (); diff -r 0c468af9dc00 -r 0549061d35b9 liboctave/array/Array.cc --- a/liboctave/array/Array.cc Tue Jun 13 11:25:31 2017 -0700 +++ b/liboctave/array/Array.cc Tue Jun 13 12:43:42 2017 -0700 @@ -2031,7 +2031,7 @@ template sortmode -Array::is_sorted (sortmode mode) const +Array::issorted (sortmode mode) const { octave_sort lsort; @@ -2056,7 +2056,7 @@ { lsort.set_compare (safe_comparator (mode, *this, false)); - if (! lsort.is_sorted (data (), n)) + if (! lsort.issorted (data (), n)) mode = UNSORTED; } @@ -2192,7 +2192,7 @@ // Attempt the O(M+N) algorithm if M is large enough. if (nval > ratio * n / octave::math::log2 (n + 1.0)) { - vmode = values.is_sorted (); + vmode = values.issorted (); // The table must not contain a NaN. if ((vmode == ASCENDING && sort_isnan (values(nval-1))) || (vmode == DESCENDING && sort_isnan (values(0)))) @@ -2462,7 +2462,7 @@ return *this; \ } \ template <> sortmode \ - Array::is_sorted (sortmode) const \ + Array::issorted (sortmode) const \ { \ return UNSORTED; \ } \ diff -r 0c468af9dc00 -r 0549061d35b9 liboctave/array/Array.h --- a/liboctave/array/Array.h Tue Jun 13 11:25:31 2017 -0700 +++ b/liboctave/array/Array.h Tue Jun 13 12:43:42 2017 -0700 @@ -702,7 +702,11 @@ sortmode mode = ASCENDING) const; //! Ordering is auto-detected or can be specified. - sortmode is_sorted (sortmode mode = UNSORTED) const; + sortmode issorted (sortmode mode = UNSORTED) const; + + OCTAVE_DEPRECATED ("use 'issorted' instead") + sortmode is_sorted (sortmode mode = UNSORTED) const + { return issorted (mode); } //! Sort by rows returns only indices. Array sort_rows_idx (sortmode mode = ASCENDING) const; diff -r 0c468af9dc00 -r 0549061d35b9 liboctave/array/Range.cc --- a/liboctave/array/Range.cc Tue Jun 13 11:25:31 2017 -0700 +++ b/liboctave/array/Range.cc Tue Jun 13 12:43:42 2017 -0700 @@ -287,7 +287,7 @@ } sortmode -Range::is_sorted (sortmode mode) const +Range::issorted (sortmode mode) const { if (rng_numel > 1 && rng_inc > 0) mode = (mode == DESCENDING) ? UNSORTED : ASCENDING; diff -r 0c468af9dc00 -r 0549061d35b9 liboctave/array/Range.h --- a/liboctave/array/Range.h Tue Jun 13 11:25:31 2017 -0700 +++ b/liboctave/array/Range.h Tue Jun 13 12:43:42 2017 -0700 @@ -107,7 +107,11 @@ Range sort (Array& sidx, octave_idx_type dim = 0, sortmode mode = ASCENDING) const; - sortmode is_sorted (sortmode mode = ASCENDING) const; + sortmode issorted (sortmode mode = ASCENDING) const; + + OCTAVE_DEPRECATED ("use 'issorted' instead") + sortmode is_sorted (sortmode mode = ASCENDING) const + { return issorted (mode); } // Support for single-index subscripting, without generating matrix cache. diff -r 0c468af9dc00 -r 0549061d35b9 liboctave/util/oct-sort.cc --- a/liboctave/util/oct-sort.cc Tue Jun 13 11:25:31 2017 -0700 +++ b/liboctave/util/oct-sort.cc Tue Jun 13 12:43:42 2017 -0700 @@ -1540,7 +1540,7 @@ template template bool -octave_sort::is_sorted (const T *data, octave_idx_type nel, Comp comp) +octave_sort::issorted (const T *data, octave_idx_type nel, Comp comp) { const T *end = data + nel; if (data != end) @@ -1560,21 +1560,21 @@ template bool -octave_sort::is_sorted (const T *data, octave_idx_type nel) +octave_sort::issorted (const T *data, octave_idx_type nel) { bool retval = false; #if defined (INLINE_ASCENDING_SORT) if (compare == ascending_compare) - retval = is_sorted (data, nel, std::less ()); + retval = issorted (data, nel, std::less ()); else #endif #if defined (INLINE_DESCENDING_SORT) if (compare == descending_compare) - retval = is_sorted (data, nel, std::greater ()); + retval = issorted (data, nel, std::greater ()); else #endif if (compare) - retval = is_sorted (data, nel, compare); + retval = issorted (data, nel, compare); return retval; } @@ -1716,7 +1716,7 @@ } else // The final column - use fast code. - sorted = is_sorted (lo, n, comp); + sorted = issorted (lo, n, comp); } return sorted; diff -r 0c468af9dc00 -r 0549061d35b9 liboctave/util/oct-sort.h --- a/liboctave/util/oct-sort.h Tue Jun 13 11:25:31 2017 -0700 +++ b/liboctave/util/oct-sort.h Tue Jun 13 12:43:42 2017 -0700 @@ -136,7 +136,11 @@ void sort (T *data, octave_idx_type *idx, octave_idx_type nel); // Check whether an array is sorted. - bool is_sorted (const T *data, octave_idx_type nel); + bool issorted (const T *data, octave_idx_type nel); + + OCTAVE_DEPRECATED ("use 'issorted' instead") + bool is_sorted (const T *data, octave_idx_type nel) + { return issorted (data, nel); } // Sort a matrix by rows, return a permutation // vector. @@ -305,7 +309,12 @@ void sort (T *data, octave_idx_type *idx, octave_idx_type nel, Comp comp); template - bool is_sorted (const T *data, octave_idx_type nel, Comp comp); + bool issorted (const T *data, octave_idx_type nel, Comp comp); + + template + OCTAVE_DEPRECATED ("use 'issorted' instead") + bool is_sorted (const T *data, octave_idx_type nel, Comp comp) + { return issorted (data, nel, comp); } template void sort_rows (const T *data, octave_idx_type *idx,