# HG changeset patch # User jwe # Date 1095282013 0 # Node ID 3f3d6eec0a2c5b255607d97bca767153462ff015 # Parent d117a9fb83be18b2891dd5eae798cdd79769e220 [project @ 2004-09-15 21:00:01 by jwe] diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2004-09-15 David Bateman + + * oct-sort.h (octave_sort::set_compare (bool (*comp) (T, T))): + New function to set the comparison function for the sort. + 2004-09-10 John W. Eaton * lo-mappers.cc (xround): Fix typo. diff --git a/liboctave/oct-sort.cc b/liboctave/oct-sort.cc --- a/liboctave/oct-sort.cc +++ b/liboctave/oct-sort.cc @@ -92,14 +92,14 @@ template octave_sort::octave_sort (void) : compare (NULL) { - merge_init ( ); + merge_init (); merge_getmem (1024); } template octave_sort::octave_sort (bool (*comp) (T, T)) : compare (comp) { - merge_init ( ); + merge_init (); merge_getmem (1024); } diff --git a/liboctave/oct-sort.h b/liboctave/oct-sort.h --- a/liboctave/oct-sort.h +++ b/liboctave/oct-sort.h @@ -109,16 +109,20 @@ class octave_sort { - public: +public: + octave_sort (void); octave_sort (bool (*comp) (T, T)); - ~octave_sort (void) { merge_freemem ( ); } + ~octave_sort (void) { merge_freemem (); } + + void set_compare (bool (*comp) (T, T)) { compare = comp; } void sort (T *v, int elements); - private: +private: + /* One MergeState exists on the stack per invocation of mergesort. It's just * a convenient way to pass state around among the helper functions. * diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-09-15 John W. Eaton + + * DLD-FUNCTIONS/sort.cc (mx_sort): Return octave_value, not + octave_value list. + 2004-09-15 David Bateman * ov.cc (octave_value::octave_value (const ArrayN&, bool)): diff --git a/src/DLD-FUNCTIONS/sort.cc b/src/DLD-FUNCTIONS/sort.cc --- a/src/DLD-FUNCTIONS/sort.cc +++ b/src/DLD-FUNCTIONS/sort.cc @@ -1,4 +1,4 @@ -/* +v/* Copyright (C) 1996, 1997 John W. Eaton Copyright (C) 2004 David Bateman @@ -50,10 +50,10 @@ }; template -static octave_value_list +static octave_value mx_sort (ArrayN &m, int dim, sortmode mode = UNDEFINED) { - octave_value_list retval; + octave_value retval; if (m.length () < 1) return retval; @@ -105,7 +105,7 @@ } } - retval(0) = octave_value (m); + retval = m; return retval; } @@ -219,7 +219,7 @@ bool ascending_compare (unsigned EIGHT_BYTE_INT a, - unsigned EIGHT_BYTE_INT b) + unsigned EIGHT_BYTE_INT b) { return (a < b); } @@ -250,10 +250,10 @@ template class octave_sort *>; template <> -static octave_value_list +static octave_value mx_sort (ArrayN &m, int dim, sortmode mode) { - octave_value_list retval; + octave_value retval; if (m.length () < 1) return retval; @@ -362,7 +362,8 @@ } } - retval(0) = m; + retval = m; + return retval; } @@ -459,6 +460,7 @@ retval(1) = idx; retval(0) = m; + return retval; }