changeset 23588:0549061d35b9

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.
author Rik <rik@octave.org>
date Tue, 13 Jun 2017 12:43:42 -0700
parents 0c468af9dc00
children 63950abd2f81
files libinterp/corefcn/data.cc libinterp/dldfcn/__ode15__.cc libinterp/octave-value/ov-base-diag.h libinterp/octave-value/ov-base-mat.h libinterp/octave-value/ov-base-scalar.h libinterp/octave-value/ov-base-sparse.h libinterp/octave-value/ov-base.cc libinterp/octave-value/ov-base.h libinterp/octave-value/ov-cell.cc libinterp/octave-value/ov-cell.h libinterp/octave-value/ov-lazy-idx.cc libinterp/octave-value/ov-lazy-idx.h libinterp/octave-value/ov-perm.h libinterp/octave-value/ov-range.h libinterp/octave-value/ov-re-mat.cc libinterp/octave-value/ov-re-mat.h libinterp/octave-value/ov.h liboctave/array/Array-d.cc liboctave/array/Array-f.cc liboctave/array/Array.cc liboctave/array/Array.h liboctave/array/Range.cc liboctave/array/Range.h liboctave/util/oct-sort.cc liboctave/util/oct-sort.h
diffstat 25 files changed, 65 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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
--- 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<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const
   { return to_dense ().sort_rows_idx (mode); }
--- 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<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const
   { return matrix.sort_rows_idx (mode); }
--- 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<octave_idx_type> sort_rows_idx (sortmode) const
--- 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
--- 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<octave_idx_type>
--- 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<octave_idx_type>
   sort_rows_idx (sortmode mode = ASCENDING) const;
--- 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<std::string> tmp = cellstr_value ();
 
-  retval = tmp.is_sorted (mode);
+  retval = tmp.issorted (mode);
 
   return retval;
 }
--- 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<octave_idx_type> &sidx, octave_idx_type dim = 0,
                      sortmode mode = ASCENDING) const;
 
-  sortmode is_sorted (sortmode mode = UNSORTED) const;
+  sortmode issorted (sortmode mode = UNSORTED) const;
 
   Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const;
 
--- 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<octave_idx_type>
--- 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<octave_idx_type> &sidx, octave_idx_type dim = 0,
                      sortmode mode = ASCENDING) const;
 
-  sortmode is_sorted (sortmode mode = UNSORTED) const;
+  sortmode issorted (sortmode mode = UNSORTED) const;
 
   Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const;
 
--- 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<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const
   { return to_dense ().sort_rows_idx (mode); }
--- 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<octave_idx_type> sort_rows_idx (sortmode) const
   { return Array<octave_idx_type> (dim_vector (1, 0)); }
--- 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<NDArray>::is_sorted (mode);
+    return octave_base_matrix<NDArray>::issorted (mode);
 }
 Array<octave_idx_type>
 octave_matrix::sort_rows_idx (sortmode mode) const
--- 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<octave_idx_type> &sidx, octave_idx_type dim = 0,
                      sortmode mode = ASCENDING) const;
 
-  sortmode is_sorted (sortmode mode = UNSORTED) const;
+  sortmode issorted (sortmode mode = UNSORTED) const;
 
   Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const;
 
--- 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<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const
   { return rep->sort_rows_idx (mode); }
--- 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<double>::is_sorted (sortmode mode) const
+Array<double>::issorted (sortmode mode) const
 {
   octave_idx_type n = numel ();
 
--- 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<float>::is_sorted (sortmode mode) const
+Array<float>::issorted (sortmode mode) const
 {
   octave_idx_type n = numel ();
 
--- 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 <typename T>
 sortmode
-Array<T>::is_sorted (sortmode mode) const
+Array<T>::issorted (sortmode mode) const
 {
   octave_sort<T> 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<T> (values(nval-1)))
           || (vmode == DESCENDING && sort_isnan<T> (values(0))))
@@ -2462,7 +2462,7 @@
     return *this;                                                       \
   }                                                                     \
   template <> sortmode                                                  \
-  Array<T>::is_sorted (sortmode) const                                  \
+  Array<T>::issorted (sortmode) const                                  \
   {                                                                     \
     return UNSORTED;                                                    \
   }                                                                     \
--- 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<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const;
--- 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;
--- 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<octave_idx_type>& 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.
 
--- 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 <typename T>
 template <typename Comp>
 bool
-octave_sort<T>::is_sorted (const T *data, octave_idx_type nel, Comp comp)
+octave_sort<T>::issorted (const T *data, octave_idx_type nel, Comp comp)
 {
   const T *end = data + nel;
   if (data != end)
@@ -1560,21 +1560,21 @@
 
 template <typename T>
 bool
-octave_sort<T>::is_sorted (const T *data, octave_idx_type nel)
+octave_sort<T>::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<T> ());
+    retval = issorted (data, nel, std::less<T> ());
   else
 #endif
 #if defined (INLINE_DESCENDING_SORT)
     if (compare == descending_compare)
-      retval = is_sorted (data, nel, std::greater<T> ());
+      retval = issorted (data, nel, std::greater<T> ());
     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;
--- 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 <typename Comp>
-  bool is_sorted (const T *data, octave_idx_type nel, Comp comp);
+  bool issorted (const T *data, octave_idx_type nel, Comp comp);
+
+  template <typename Comp>
+  OCTAVE_DEPRECATED ("use 'issorted' instead")
+  bool is_sorted (const T *data, octave_idx_type nel, Comp comp)
+  { return issorted (data, nel, comp); }
 
   template <typename Comp>
   void sort_rows (const T *data, octave_idx_type *idx,