bug-gnu-pspp
[Top][All Lists]
Advanced

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

PSPP-BUG: Re: [bug #12931] ONEWAY transposes output rows/columns


From: John Darrington
Subject: PSPP-BUG: Re: [bug #12931] ONEWAY transposes output rows/columns
Date: Tue, 3 May 2005 06:40:48 +0800
User-agent: Mutt/1.5.4i

On Mon, May 02, 2005 at 10:50:08AM -0700, Ben Pfaff wrote:

     > From hash.c:
     > /* Sorts hash table H based on hash comparison function.
     >    ....  After calling this function, only hsh_destroy()
     >    and hsh_count() may be applied to H. */
     >
     > This implies that it's not safe to iterate a hash after sorting it.  
     > Is it safe to do so?  And after sorting, will it iterate in the sorted
     > order?  
     
     Hmm.  I hadn't considered this question.  The purpose of
     hsh_sort() is to transform a hash table into a sorted array, so
     that afterward you just iterate through the sorted array that it
     returns.  The sorted array is no longer a hash table, so you
     can't use, say, hsh_probe() or hsh_find() or hsh_delete() on it.
     It should work just fine for iteration with hsh_first/next(), but
     why not just step through the array it returns?

     In other words, the usage is something like this:
     
             table = hsh_create (...);
             ...Insert lots of stuff into hash table...
             for (array = hsh_sort (...); *array != NULL; array++) {
                 ...Do something with *array, but don't use hash functions...
             }
             hsh_destroy (table);
     
You're right.  I don't know why I didn't do like that to begin with
--- probably because I wasn't aware of the  hsh_sort function at
that time.  Ben, have you any reason for putting the comments
describing how to use functions only in the *.c files?  I'm used to
looking for such comments in the header files.

     
     Hmm.  Perhaps I should enforce the hsh_sort() constraints with
     some assertions.
     
I think that would be a good idea.  Then there's no question of what's
allowed and what's not.

J'

-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.


Attachment: pgp0kDS0z03QI.pgp
Description: PGP signature


reply via email to

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