Re: [BLACKBOX] Sorting a Dialog.List

From: Stephen R. Troy <"Stephen>
Date: Thu, 13 Sep 2012 10:58:17 -0700

Werner and Robert, thanks for your suggestions.
  
I did ask a newbie question, about the inner workings of a Black Box distribution module. I've only been using Black Box on and off for going on two years now, and am still getting used to its peculiarities and trying to understand its version of object-oriented programming. Overall, I started programming digital computers in 1957, so in that sense I'm no newbie -- I'm an engineer, and develop programs to carry out engineering and operations research tasks -- I don't develop software as stand-alone products. I've used FORTRAN and BASIC, various assemblers and several flavors of machine language, mainframes, minis and desktop machines -- experienced the joys of punched paper tape and punched cards -- switched to Pascal in the mid-80s, and then Modula-2.

I'm retired now, and this program I'm working on is a hobby project. I had coded it in XDS Modula-2, but for various reasons I'm now migrating it to Black Box. I'm not worried about having 33,000 choices in a list box, because as long as they're sorted, it's easy to scroll to find the one wanted -- did this in XDS and it worked fine.


Even a bubble sort would be much faster if it could be run inside the Dialog module. Although it would still be On^2, almost all of those times it would not be necessary to read out two complete strings in order to do a comparison -- the first one or two characters would be enough -- whereas from outside the Dialog module, Dialog.GetItem has to read out the entire string every time. But this could only be done either inside the Dialog module or by exporting the List record from the Dialog module, either of which requires modifying a Black Box distribution module, which as a Black Box newbie I'm still nervous about. That was why I was asking about possible alternatives. Other times people on this list have kindly pointed out solutions that I had not seen because they were in a part of Black Box where I had not thought to look.

Again, thanks to all for your suggestions.

Steve Troy in Maryland USA


        -------- Original Message --------
        Subject: Re: [BLACKBOX] Sorting a Dialog.List
        From: Robert <robert.campbell_{([at]})nowhere.xy
        Date: Fri, September 07, 2012 3:00 pm
        To: BLACKBOX{([at]})nowhere.xy
        
        Steve
        
        I think you are misleading us - this is not a 'newbie' question!
        
        My guess that your list was short was pretty comprehensively wrong!
        
        Get / Set item seems to scan the list to find the item, so that makes a Bubble
        sort n^3. That shoud give time for the icecap to refreeze.
        
        Do you expect the user to select items from your 33000 element list using a mouse and a DropDown GUI?
        Or are you just using the Dialog.List as a convenient internal data structure for your algorithm?
        
        If the latter you could try Module LibCycles (same URL as before). It implements a doubly linked list (which
        I think is better for this kind of task) and a Merge sort.
        
        The Merge sort is n * Ln n, both on average and worst case. For that reason I prefer it to QuickSort, which has bad worst case performance.
        
        
        Regards
        
        Robert
        
        
        
        On 07/09/2012 16:34, Stephen R. Troy wrote:
        

                
                Thanks, Robert, but this method, with GetItem and SetItem, involves reading the complete entries out of the list and then writing them back in at a different position, which is very slow. I was hoping for a method that simply swapped the StrList.items, which are apparently pointers to the list entries, leaving the entries themselves in place, which would obviously be much faster. Unfortunately these are not accessible from outside the Dialog module. My list is currently up to about 33,000 entries. So an external bubble sort works, acceptably fast on a small test list, but with the full 33,000 and the bubble sort's n^2 time, the polar icecap is melting faster. I guess next I'll try to implement a QuickSort. Thanks anyway,
                Steve Troy in Maryland USA
                

                        -------- Original Message --------
                        Subject: Re: [BLACKBOX] Sorting a Dialog.List
                        From: Robert <robert.campbell_{([at]})nowhere.xy
                        Date: Thu, September 06, 2012 6:03 pm
                        To: BLACKBOX{([at]})nowhere.xy
                        
                        
                        Stephen
                        
                        The following routine (from LibMisc on CPC http://www.zinnamturm.eu/downloadsIN.htm#Lib) is a 'clunky' way of solving a different
                        problem, but it might give you some ideas.
                        
                        The Docu & Mod extracts are:
                        
                        
                        
                        
                        
                        
                        
                        
                        I would guess that your lists are fairly short, so a simple Bubble sort would be fine?
                        
                        
                        Cheers
                        
                        Robert.
                        
                        
                        
                        On 06/09/2012 21:40, Stephen R. Troy wrote:
                        

                                
                                Dear List, another newbie question: is there a non-clunky way to sort the items in a Dialog.List object? I'm nervous about going inside the Dialog module, and apparently the individual "items" in the List are not accessible from outside the Dialog module. Hint, hint: it sure would be swell if a new release included such a Sort method. Obviously I could do my sorting before entering the items into the list, but for various reasons this would be clumsy. Any suggestions appreciated.
                                Steve Troy in Maryland USA

                                No virus found in this message.
                                Checked by AVG - www.avg.com
                                Version: 2012.0.2197 / Virus Database: 2437/5252 - Release Date: 09/06/12
                                ---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy


                        ---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy

                No virus found in this message.
                Checked by AVG - www.avg.com
                Version: 2012.0.2197 / Virus Database: 2437/5254 - Release Date: 09/07/12
                ---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy


        ---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy

---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy

Werner and Robert, thanks for your suggestions.
 
I did ask a newbie question, about the inner workings of a Black Box distribution module.  I've only been using Black Box on and off for going on two years now, and am still getting used to its peculiarities and trying to understand its version of object-oriented programming.  Overall, I started programming digital computers in 1957, so in that sense I'm no newbie -- I'm an engineer, and develop programs to carry out engineering and operations research tasks -- I don't develop software as stand-alone products.  I've used FORTRAN and BASIC, various assemblers and several flavors of machine language, mainframes, minis and desktop machines -- experienced the joys of punched paper tape and punched cards -- switched to Pascal in the mid-80s, and then Modula-2. 

I'm retired now, and this program I'm working on is a hobby project.  I had coded it in XDS Modula-2, but for various reasons I'm now migrating it to Black Box.  I'm not worried about having 33,000 choices in a list box, because as long as they're sorted, it's easy to scroll to find the one wanted -- did this in XDS and it worked fine.

Even a bubble sort would be much faster if it could be run inside the Dialog module.  Although it would still be On^2, almost all of those times it would not be necessary to read out two complete strings in order to do a comparison -- the first one or two characters would be enough -- whereas from outside the Dialog module, Dialog.GetItem has to read out the entire string every time.  But this could only be done either inside the Dialog module or by exporting the List record from the Dialog module, either of which requires modifying a Black Box distribution module, which as a Black Box newbie I'm still nervous about.  That was why I was asking about possible alternatives.  Other times people on this list have kindly pointed out solutions that I had not seen because they were in a part of Black Box where I had not thought to look.

Again, thanks to all for your suggestions.

Steve Troy in Maryland USA
-------- Original Message --------
Subject: Re: [BLACKBOX] Sorting a Dialog.List
From: Robert <On 07/09/2012 16:34, Stephen R. Troy wrote:
www.avg.com
Version: 2012.0.2197 / Virus Database: 2437/5252 - Release Date: 09/06/12
---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to
(image/png attachment:
part5.07040207.09070906___at___nowhere.xy)

part4.05080006.07080403___at___nowhere.xy
(image/png attachment: part4.05080006.07080403___at___nowhere.xy)

Received on Thu Sep 13 2012 - 19:58:17 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:29:56 UTC