Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,45 @@
|
|||
' Written by Sanmayce, 2021-Oct-29
|
||||
' The indexes are signed, but the elements are unsigned.
|
||||
_Define A-Z As _INTEGER64
|
||||
Sub Quicksort_QB64 (QWORDS~&&())
|
||||
Left = LBound(QWORDS~&&)
|
||||
Right = UBound(QWORDS~&&)
|
||||
LeftMargin = Left
|
||||
ReDim Stack&&(Left To Right)
|
||||
StackPtr = 0
|
||||
StackPtr = StackPtr + 1
|
||||
Stack&&(StackPtr + LeftMargin) = Left
|
||||
StackPtr = StackPtr + 1
|
||||
Stack&&(StackPtr + LeftMargin) = Right
|
||||
Do 'Until StackPtr = 0
|
||||
Right = Stack&&(StackPtr + LeftMargin)
|
||||
StackPtr = StackPtr - 1
|
||||
Left = Stack&&(StackPtr + LeftMargin)
|
||||
StackPtr = StackPtr - 1
|
||||
Do 'Until Left >= Right
|
||||
Pivot~&& = QWORDS~&&((Left + Right) \ 2)
|
||||
Indx = Left
|
||||
Jndx = Right
|
||||
Do
|
||||
Do While (QWORDS~&&(Indx) < Pivot~&&)
|
||||
Indx = Indx + 1
|
||||
Loop
|
||||
Do While (QWORDS~&&(Jndx) > Pivot~&&)
|
||||
Jndx = Jndx - 1
|
||||
Loop
|
||||
If Indx <= Jndx Then
|
||||
If Indx < Jndx Then Swap QWORDS~&&(Indx), QWORDS~&&(Jndx)
|
||||
Indx = Indx + 1
|
||||
Jndx = Jndx - 1
|
||||
End If
|
||||
Loop While Indx <= Jndx
|
||||
If Indx < Right Then
|
||||
StackPtr = StackPtr + 1
|
||||
Stack&&(StackPtr + LeftMargin) = Indx
|
||||
StackPtr = StackPtr + 1
|
||||
Stack&&(StackPtr + LeftMargin) = Right
|
||||
End If
|
||||
Right = Jndx
|
||||
Loop Until Left >= Right
|
||||
Loop Until StackPtr = 0
|
||||
End Sub
|
||||
Loading…
Add table
Add a link
Reference in a new issue