Mercurial > hg > octave-nkf
changeset 4998:3f3d6eec0a2c
[project @ 2004-09-15 21:00:01 by jwe]
author | jwe |
---|---|
date | Wed, 15 Sep 2004 21:00:13 +0000 |
parents | d117a9fb83be |
children | 5538e4ceb616 |
files | liboctave/ChangeLog liboctave/oct-sort.cc liboctave/oct-sort.h src/ChangeLog src/DLD-FUNCTIONS/sort.cc |
diffstat | 5 files changed, 29 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2004-09-15 David Bateman <dbateman@free.fr> + + * oct-sort.h (octave_sort<T>::set_compare (bool (*comp) (T, T))): + New function to set the comparison function for the sort. + 2004-09-10 John W. Eaton <jwe@octave.org> * lo-mappers.cc (xround): Fix typo.
--- a/liboctave/oct-sort.cc +++ b/liboctave/oct-sort.cc @@ -92,14 +92,14 @@ template <class T> octave_sort<T>::octave_sort (void) : compare (NULL) { - merge_init ( ); + merge_init (); merge_getmem (1024); } template <class T> octave_sort<T>::octave_sort (bool (*comp) (T, T)) : compare (comp) { - merge_init ( ); + merge_init (); merge_getmem (1024); }
--- 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. *
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-09-15 John W. Eaton <jwe@octave.org> + + * DLD-FUNCTIONS/sort.cc (mx_sort): Return octave_value, not + octave_value list. + 2004-09-15 David Bateman <dbateman@free.fr> * ov.cc (octave_value::octave_value (const ArrayN<char>&, bool)):
--- 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 <class T> -static octave_value_list +static octave_value mx_sort (ArrayN<T> &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<vec_index<unsigned EIGHT_BYTE_INT> *>; template <> -static octave_value_list +static octave_value mx_sort (ArrayN<double> &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; }