changeset 8823:3efa512a0957

make issorted work for cells
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 20 Feb 2009 07:44:48 +0100
parents 40ff50ce3052
children 76ddf0ab985d
files src/ChangeLog src/ov-cell.cc src/ov-cell.h
diffstat 3 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Feb 20 07:33:40 2009 +0100
+++ b/src/ChangeLog	Fri Feb 20 07:44:48 2009 +0100
@@ -2,6 +2,9 @@
 
 	* ov-base-mat.cc (octave_base_matrix<MT>::do_index_op):
 	Correctly compute all-scalar index.
+	* ov-cell.cc (octave_cell::is_sorted, octave_cell::is_sorted_rows):
+	New methods.
+	* ov-cell.h: Declare them.
 
 2009-02-20  John W. Eaton  <jwe@octave.org>
 
--- a/src/ov-cell.cc	Fri Feb 20 07:33:40 2009 +0100
+++ b/src/ov-cell.cc	Fri Feb 20 07:44:48 2009 +0100
@@ -483,6 +483,24 @@
   return retval;
 }
 
+sortmode 
+octave_cell::is_sorted (sortmode mode) const
+{
+  sortmode retval = UNSORTED;
+
+  if (is_cellstr ())
+    {
+      Array<std::string> tmp = cellstr_value ();
+
+      retval = tmp.is_sorted (mode);
+    }
+  else
+    error ("issorted: not a cell array of strings");
+  
+  return retval;
+}
+
+
 Array<octave_idx_type>
 octave_cell::sort_rows_idx (sortmode mode) const
 {
@@ -500,6 +518,23 @@
   return retval;
 }
 
+sortmode 
+octave_cell::is_sorted_rows (sortmode mode) const
+{
+  sortmode retval = UNSORTED;
+
+  if (is_cellstr ())
+    {
+      Array<std::string> tmp = cellstr_value ();
+
+      retval = tmp.is_sorted_rows (mode);
+    }
+  else
+    error ("issorted: not a cell array of strings");
+  
+  return retval;
+}
+
 bool
 octave_cell::is_true (void) const
 {
--- a/src/ov-cell.h	Fri Feb 20 07:33:40 2009 +0100
+++ b/src/ov-cell.h	Fri Feb 20 07:44:48 2009 +0100
@@ -99,8 +99,12 @@
   octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
 		     sortmode mode = ASCENDING) const;
 
+  sortmode is_sorted (sortmode mode = UNSORTED) const;
+
   Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const;
 
+  sortmode is_sorted_rows (sortmode mode = UNSORTED) const;
+
   bool is_matrix_type (void) const { return false; }
 
   bool is_numeric_type (void) const { return false; }