octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: issorted & sortrows


From: Jaroslav Hajek
Subject: Re: issorted & sortrows
Date: Thu, 12 Feb 2009 21:56:54 +0100

On Thu, Feb 12, 2009 at 9:10 PM, John W. Eaton <address@hidden> wrote:
> On 12-Feb-2009, dbateman wrote:
>
> | Jaroslav Hajek-2 wrote:
> |
> | > I think these are used for sorting cell arrays.
> |
> | I confirm that they are used to sort cell string arrays
>
> OK, I checked in the following change:
>
>  http://hg.savannah.gnu.org/hgweb/octave/rev/a669df7beb73
>
> (sorry about the useless hg log message).  This change restricts
> sorting on cell arrays to cell arrays of strings only, by implementing
> octave_cell::sort and octave_cell::sortrows_idx methods that ensure
> that the cell array contains only strings, and then converts the array
> of octave_value objects to an array of std::string objects before
> doing the sort, then creates a new .  It might be good to have a way
> to avoid doing the conversion if the array is already sorted, but I
> don't see a way to do that since the is_sorted functions always seem
> to examine the values.  Would it be worth caching the sort mode in the
> Array?  When creating a cell from an Array<std::string> object, we
> could copy the sort mode as well, then the octave_cell::sort function
> could skip the sort without having to first convert the
> Array<octave_value> object to an Array<std::string> object.
>
> Does that make sense?  Does it seem worth the effort?
>
> jwe
>

Here's a different suggestion: given the fact that cells are often
used as cells of strings, maybe we could cache the cellstr value in
Cell, and invalidate it on modifications? (or check for string
modifications)?
This may be useful for more built-in functions operating on cell
arrays of strings.

cheers

-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]