Author Topic: Call for Library Submissions  (Read 7152 times)

0 Members and 1 Guest are viewing this topic.

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: Call for Library Submissions
« Reply #15 on: September 02, 2021, 12:28:25 pm »
Seems there was some really good discussions on different Sorting Routines with sample code and some really good discussions and routines for Child Windows. Could these be captured in our Library or are they not the type or standards for the Library?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Call for Library Submissions
« Reply #16 on: September 02, 2021, 01:15:29 pm »
Seems there was some really good discussions on different Sorting Routines with sample code and some really good discussions and routines for Child Windows. Could these be captured in our Library or are they not the type or standards for the Library?

I think code should be posted in Programs so that feedback and updates can be tracked publicly.

Steve has nice Memory sort in Library and qsort is very good general purpose sorter and should serve most very well. Sure, for special cases there are better, for special cases, and for those who want to track all those checkout Rosetta Code and all their variations.

Child Windows sounds interesting, someone have something easy and dependable?

Does anyone need a copy of Qsort?

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: Call for Library Submissions
« Reply #17 on: September 02, 2021, 01:28:06 pm »
I don't believe I have come across Qsort. I would be interested in a sample code for this routine. Thanks b+

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Call for Library Submissions
« Reply #18 on: September 02, 2021, 02:41:33 pm »
Using Q short for Quick maybe you've seen that before :)
https://en.wikipedia.org/wiki/Quicksort

I threw together a Q Demo:
Code: QB64: [Select]
  1. Const nItems = 100
  2. ReDim Shared sa$(1 To nItems) 'setup with string array sa$() shared so dont have to pass as parameter
  3. For x = 1 To nItems ' make a random list to sort
  4.     b$ = ""
  5.     r = (Rnd * 5) \ 1 + 2
  6.     For i = 0 To r
  7.         b$ = b$ + Mid$("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.?", (Rnd * 64) \ 1 + 1, 1)
  8.     Next
  9.     sa$(x) = b$
  10.     Print b$,
  11. Print "Press any to sort"
  12. QSort 1, nItems
  13. For i = 1 To nItems
  14.     Print sa$(i),
  15.  
  16.  
  17. ' modified for QB64 from JB
  18. ' This is the best all purpose sort routine around, don't worry how it works, it just does!
  19. ' To use this sub rountine store all the string values you want to sort into sa$() array
  20. ' call Qsort with Start = 1 and Finish = number of Items in your array
  21. Sub QSort (Start, Finish) 'sa$ needs to be   DIM SHARED !!!!     array
  22.     Dim i As Long, j As Long, x$
  23.     i = Start
  24.     j = Finish
  25.     x$ = sa$(Int((i + j) / 2))
  26.     While i <= j
  27.         While sa$(i) < x$
  28.             i = i + 1
  29.         Wend
  30.         While sa$(j) > x$
  31.             j = j - 1
  32.         Wend
  33.         If i <= j Then '<< makes this an ascending sort
  34.             Swap sa$(i), sa$(j)
  35.             i = i + 1
  36.             j = j - 1
  37.         End If
  38.     Wend
  39.     If j > Start Then QSort Start, j
  40.     If i < Finish Then QSort i, Finish

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: Call for Library Submissions
« Reply #19 on: September 02, 2021, 03:19:40 pm »
Ya that's the quick sort I've been using and you are right, best one for stuff I do but I use it for values and can see now how it works with string arrays. Thanks B+

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Call for Library Submissions
« Reply #20 on: September 02, 2021, 04:08:04 pm »
I think what makes it an ascending sort is commented wrong, it's the compares to the pivot x$ that determines ascending or descending which BTW I made half way between to save time as opposed to random pivot.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Call for Library Submissions
« Reply #21 on: September 03, 2021, 05:38:13 am »
@Dimster @bplus There is a thread (as Dimster says) on Sort Routines, and likewise I did think at the time that this might be  a Library entry.  I'll investigate & discuss with bplus.  Maybe look at Child Windows later.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Call for Library Submissions
« Reply #22 on: September 05, 2021, 05:26:48 am »
Guess we can add it it now @bplus,

the function is online for 5 days now, has more than 200 views and several replies by other members, but no obvious error reports.

https://www.qb64.org/forum/index.php?topic=4142.0

Rho, you're blocking my Personal Messages.  Could you unblock?  The Library Cataloguer (me) likes to discuss any private matters relating to the Library there.  Thanks, Qwerkey

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Call for Library Submissions
« Reply #23 on: September 05, 2021, 05:28:56 am »
Apologies to general membership, should have put @RhoSigma in previous reply.

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Call for Library Submissions
« Reply #24 on: September 05, 2021, 05:34:25 am »
Rho, you're blocking my Personal Messages.  Could you unblock?  The Library Cataloguer (me) likes to discuss any private matters relating to the Library there.  Thanks, Qwerkey

Ok, @Qwerkey it's unblocked now for all members...
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack