diff liboctave/Array.h @ 1756:1af643fa00e3

[project @ 1996-01-22 04:55:17 by jwe]
author jwe
date Mon, 22 Jan 1996 04:55:17 +0000
parents d2ee993d40cd
children e090f89bf2f5
line wrap: on
line diff
--- a/liboctave/Array.h
+++ b/liboctave/Array.h
@@ -31,6 +31,7 @@
 #define HEAVYWEIGHT_INDEXING 1
 
 #include <cassert>
+#include <cstdlib>
 
 #include "lo-error.h"
 
@@ -86,6 +87,11 @@
     T& elem (int n) { return data[n]; }
 
     T elem (int n) const { return data[n]; }
+
+    void qsort (int (*compare) (const void *, const void *))
+      {
+	::qsort (data, len, sizeof (T), compare);
+      }
   };
 
 #ifdef HEAVYWEIGHT_INDEXING
@@ -182,6 +188,17 @@
 
   T *fortran_vec (void);
 
+  void qsort (int (*compare) (const void *, const void *))
+    {
+      if (rep->count > 1)
+	{
+	  --rep->count;
+	  rep = new ArrayRep (*rep);
+	}
+
+      rep->qsort (compare);
+    }
+
 #ifdef HEAVYWEIGHT_INDEXING
   void set_max_indices (int mi) { max_indices = mi; }