Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
grymmjack committed Jun 22, 2024
2 parents 496fb91 + 71b1296 commit 9b6bed1
Show file tree
Hide file tree
Showing 18 changed files with 521 additions and 5 deletions.
34 changes: 34 additions & 0 deletions ARR/ARR_BYTE.BAS
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,37 @@ SUB ARR_BYTE.quicksort(arr%%(), start%, finish%, order%)
CALL ARR_BYTE.quicksort(arr%%(), pivot% + 1, finish%, order%)
END IF
END SUB



''
' Combine two arrays - requires both array indexes are serial with no gaps
'
' @param _BYTE ARRAY source_arr%%() array to combine
' @param _BYTE ARRAY dest_arr%%() array to store combined result
'
SUB ARR_BYTE.union(source_arr%%(), dest_arr%%())
's = source, d = dest, n = new
'lb = lower bounds, ub = upper bounds
't = total elements
DIM AS LONG s_ub, s_lb, s_t
DIM AS LONG d_ub, d_lb, d_t
DIM AS LONG n_lb, n_ub, n_t
DIM AS LONG i, n

s_lb& = LBOUND(source_arr%%)
s_ub& = UBOUND(source_arr%%)
d_lb& = LBOUND(dest_arr%%)
d_ub& = UBOUND(dest_arr%%)
s_t& = (s_ub& - s_lb&)
d_t& = (d_ub& - d_lb&)
n_t& = s_t& + d_t&
n_lb& = d_lb&
n_ub& = d_ub& + s_t& + 1

REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS _BYTE
FOR i& = s_lb& TO s_ub&
n& = d_ub& + 1 + i& - s_lb&
dest_arr%%(n&) = source_arr%%(i&)
NEXT i&
END SUB
34 changes: 34 additions & 0 deletions ARR/ARR_DBL.BAS
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,37 @@ SUB ARR_DBL.quicksort(arr#(), start%, finish%, order%)
CALL ARR_DBL.quicksort(arr#(), pivot% + 1, finish%, order%)
END IF
END SUB



''
' Combine two arrays - requires both array indexes are serial with no gaps
'
' @param DOUBLE ARRAY source_arr#() array to combine
' @param DOUBLE ARRAY dest_arr#() array to store combined result
'
SUB ARR_DBL.union(source_arr#(), dest_arr#())
's = source, d = dest, n = new
'lb = lower bounds, ub = upper bounds
't = total elements
DIM AS LONG s_ub, s_lb, s_t
DIM AS LONG d_ub, d_lb, d_t
DIM AS LONG n_lb, n_ub, n_t
DIM AS LONG i, n

s_lb& = LBOUND(source_arr#)
s_ub& = UBOUND(source_arr#)
d_lb& = LBOUND(dest_arr#)
d_ub& = UBOUND(dest_arr#)
s_t& = (s_ub& - s_lb&)
d_t& = (d_ub& - d_lb&)
n_t& = s_t& + d_t&
n_lb& = d_lb&
n_ub& = d_ub& + s_t& + 1

REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS DOUBLE
FOR i& = s_lb& TO s_ub&
n& = d_ub& + 1 + i& - s_lb&
dest_arr#(n&) = source_arr#(i&)
NEXT i&
END SUB
34 changes: 34 additions & 0 deletions ARR/ARR_FLT.BAS
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,37 @@ SUB ARR_FLT.quicksort(arr##(), start%, finish%, order%)
CALL ARR_FLT.quicksort(arr##(), pivot% + 1, finish%, order%)
END IF
END SUB



''
' Combine two arrays - requires both array indexes are serial with no gaps
'
' @param _FLOAT ARRAY source_arr##() array to combine
' @param _FLOAT ARRAY dest_arr##() array to store combined result
'
SUB ARR_FLT.union(source_arr##(), dest_arr##())
's = source, d = dest, n = new
'lb = lower bounds, ub = upper bounds
't = total elements
DIM AS LONG s_ub, s_lb, s_t
DIM AS LONG d_ub, d_lb, d_t
DIM AS LONG n_lb, n_ub, n_t
DIM AS LONG i, n

s_lb& = LBOUND(source_arr##)
s_ub& = UBOUND(source_arr##)
d_lb& = LBOUND(dest_arr##)
d_ub& = UBOUND(dest_arr##)
s_t& = (s_ub& - s_lb&)
d_t& = (d_ub& - d_lb&)
n_t& = s_t& + d_t&
n_lb& = d_lb&
n_ub& = d_ub& + s_t& + 1

REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS _FLOAT
FOR i& = s_lb& TO s_ub&
n& = d_ub& + 1 + i& - s_lb&
dest_arr##(n&) = source_arr##(i&)
NEXT i&
END SUB
34 changes: 34 additions & 0 deletions ARR/ARR_INT.BAS
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,37 @@ SUB ARR_INT.quicksort(arr%(), start%, finish%, order%)
CALL ARR_INT.quicksort(arr%(), pivot% + 1, finish%, order%)
END IF
END SUB



''
' Combine two arrays - requires both array indexes are serial with no gaps
'
' @param INTEGER ARRAY source_arr%() array to combine
' @param INTEGER ARRAY dest_arr%() array to store combined result
'
SUB ARR_INT.union(source_arr%(), dest_arr%())
's = source, d = dest, n = new
'lb = lower bounds, ub = upper bounds
't = total elements
DIM AS LONG s_ub, s_lb, s_t
DIM AS LONG d_ub, d_lb, d_t
DIM AS LONG n_lb, n_ub, n_t
DIM AS LONG i, n

s_lb& = LBOUND(source_arr%)
s_ub& = UBOUND(source_arr%)
d_lb& = LBOUND(dest_arr%)
d_ub& = UBOUND(dest_arr%)
s_t& = (s_ub& - s_lb&)
d_t& = (d_ub& - d_lb&)
n_t& = s_t& + d_t&
n_lb& = d_lb&
n_ub& = d_ub& + s_t& + 1

REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS INTEGER
FOR i& = s_lb& TO s_ub&
n& = d_ub& + 1 + i& - s_lb&
dest_arr%(n&) = source_arr%(i&)
NEXT i&
END SUB
34 changes: 34 additions & 0 deletions ARR/ARR_INT64.BAS
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,37 @@ SUB ARR_INT64.quicksort(arr&&(), start%, finish%, order%)
CALL ARR_INT64.quicksort(arr&&(), pivot% + 1, finish%, order%)
END IF
END SUB



''
' Combine two arrays - requires both array indexes are serial with no gaps
'
' @param _INTEGER64 ARRAY source_arr&&() array to combine
' @param _INTEGER64 ARRAY dest_arr&&() array to store combined result
'
SUB ARR_INT64.union(source_arr&&(), dest_arr&&())
's = source, d = dest, n = new
'lb = lower bounds, ub = upper bounds
't = total elements
DIM AS LONG s_ub, s_lb, s_t
DIM AS LONG d_ub, d_lb, d_t
DIM AS LONG n_lb, n_ub, n_t
DIM AS LONG i, n

s_lb& = LBOUND(source_arr&&)
s_ub& = UBOUND(source_arr&&)
d_lb& = LBOUND(dest_arr&&)
d_ub& = UBOUND(dest_arr&&)
s_t& = (s_ub& - s_lb&)
d_t& = (d_ub& - d_lb&)
n_t& = s_t& + d_t&
n_lb& = d_lb&
n_ub& = d_ub& + s_t& + 1

REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS _INTEGER64
FOR i& = s_lb& TO s_ub&
n& = d_ub& + 1 + i& - s_lb&
dest_arr&&(n&) = source_arr&&(i&)
NEXT i&
END SUB
34 changes: 34 additions & 0 deletions ARR/ARR_LONG.BAS
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,37 @@ SUB ARR_LONG.quicksort(arr&(), start%, finish%, order%)
CALL ARR_LONG.quicksort(arr&(), pivot% + 1, finish%, order%)
END IF
END SUB



''
' Combine two arrays - requires both array indexes are serial with no gaps
'
' @param LONG ARRAY source_arr&() array to combine
' @param LONG ARRAY dest_arr&() array to store combined result
'
SUB ARR_LONG.union(source_arr&(), dest_arr&())
's = source, d = dest, n = new
'lb = lower bounds, ub = upper bounds
't = total elements
DIM AS LONG s_ub, s_lb, s_t
DIM AS LONG d_ub, d_lb, d_t
DIM AS LONG n_lb, n_ub, n_t
DIM AS LONG i, n

s_lb& = LBOUND(source_arr&)
s_ub& = UBOUND(source_arr&)
d_lb& = LBOUND(dest_arr&)
d_ub& = UBOUND(dest_arr&)
s_t& = (s_ub& - s_lb&)
d_t& = (d_ub& - d_lb&)
n_t& = s_t& + d_t&
n_lb& = d_lb&
n_ub& = d_ub& + s_t& + 1

REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS LONG
FOR i& = s_lb& TO s_ub&
n& = d_ub& + 1 + i& - s_lb&
dest_arr&(n&) = source_arr&(i&)
NEXT i&
END SUB
34 changes: 34 additions & 0 deletions ARR/ARR_SNG.BAS
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,37 @@ SUB ARR_SNG.quicksort(arr!(), start%, finish%, order%)
CALL ARR_SNG.quicksort(arr!(), pivot% + 1, finish%, order%)
END IF
END SUB



''
' Combine two arrays - requires both array indexes are serial with no gaps
'
' @param SINGLE ARRAY source_arr!() array to combine
' @param SINGLE ARRAY dest_arr!() array to store combined result
'
SUB ARR_SNG.union(source_arr!(), dest_arr!())
's = source, d = dest, n = new
'lb = lower bounds, ub = upper bounds
't = total elements
DIM AS LONG s_ub, s_lb, s_t
DIM AS LONG d_ub, d_lb, d_t
DIM AS LONG n_lb, n_ub, n_t
DIM AS LONG i, n

s_lb& = LBOUND(source_arr!)
s_ub& = UBOUND(source_arr!)
d_lb& = LBOUND(dest_arr!)
d_ub& = UBOUND(dest_arr!)
s_t& = (s_ub& - s_lb&)
d_t& = (d_ub& - d_lb&)
n_t& = s_t& + d_t&
n_lb& = d_lb&
n_ub& = d_ub& + s_t& + 1

REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS SINGLE
FOR i& = s_lb& TO s_ub&
n& = d_ub& + 1 + i& - s_lb&
dest_arr!(n&) = source_arr!(i&)
NEXT i&
END SUB
33 changes: 33 additions & 0 deletions ARR/ARR_STR.BAS
Original file line number Diff line number Diff line change
Expand Up @@ -623,3 +623,36 @@ SUB ARR_STR.quicksort(arr$(), start%, finish%, order%)
CALL ARR_STR.quicksort(arr$(), pivot% + 1, finish%, order%)
END IF
END SUB


''
' Combine two arrays - requires both array indexes are serial with no gaps
'
' @param STRING ARRAY source_arr$() array to combine
' @param STRING ARRAY dest_arr$() array to store combined result
'
SUB ARR_STR.union(source_arr$(), dest_arr$())
's = source, d = dest, n = new
'lb = lower bounds, ub = upper bounds
't = total elements
DIM AS LONG s_ub, s_lb, s_t
DIM AS LONG d_ub, d_lb, d_t
DIM AS LONG n_lb, n_ub, n_t
DIM AS LONG i, n

s_lb& = LBOUND(source_arr$)
s_ub& = UBOUND(source_arr$)
d_lb& = LBOUND(dest_arr$)
d_ub& = UBOUND(dest_arr$)
s_t& = (s_ub& - s_lb&)
d_t& = (d_ub& - d_lb&)
n_t& = s_t& + d_t&
n_lb& = d_lb&
n_ub& = d_ub& + s_t& + 1

REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS STRING
FOR i& = s_lb& TO s_ub&
n& = d_ub& + 1 + i& - s_lb&
dest_arr$(n&) = source_arr$(i&)
NEXT i&
END SUB
34 changes: 34 additions & 0 deletions ARR/ARR_TEMPLATE.BAS
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,37 @@ SUB ARR_{UT}.quicksort(arr{SY}(), start%, finish%, order%)
CALL ARR_{UT}.quicksort(arr{SY}(), pivot% + 1, finish%, order%)
END IF
END SUB



''
' Combine two arrays - requires both array indexes are serial with no gaps
'
' @param {Q} ARRAY source_arr{SY}() array to combine
' @param {Q} ARRAY dest_arr{SY}() array to store combined result
'
SUB ARR_{UT}.union(source_arr{SY}(), dest_arr{SY}())
's = source, d = dest, n = new
'lb = lower bounds, ub = upper bounds
't = total elements
DIM AS LONG s_ub, s_lb, s_t
DIM AS LONG d_ub, d_lb, d_t
DIM AS LONG n_lb, n_ub, n_t
DIM AS LONG i, n

s_lb& = LBOUND(source_arr{SY})
s_ub& = UBOUND(source_arr{SY})
d_lb& = LBOUND(dest_arr{SY})
d_ub& = UBOUND(dest_arr{SY})
s_t& = (s_ub& - s_lb&)
d_t& = (d_ub& - d_lb&)
n_t& = s_t& + d_t&
n_lb& = d_lb&
n_ub& = d_ub& + s_t& + 1

REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS {Q}
FOR i& = s_lb& TO s_ub&
n& = d_ub& + 1 + i& - s_lb&
dest_arr{SY}(n&) = source_arr{SY}(i&)
NEXT i&
END SUB
34 changes: 34 additions & 0 deletions ARR/ARR_UBYTE.BAS
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,37 @@ SUB ARR_UBYTE.quicksort(arr~%%(), start%, finish%, order%)
CALL ARR_UBYTE.quicksort(arr~%%(), pivot% + 1, finish%, order%)
END IF
END SUB



''
' Combine two arrays - requires both array indexes are serial with no gaps
'
' @param _UNSIGNED _BYTE ARRAY source_arr~%%() array to combine
' @param _UNSIGNED _BYTE ARRAY dest_arr~%%() array to store combined result
'
SUB ARR_UBYTE.union(source_arr~%%(), dest_arr~%%())
's = source, d = dest, n = new
'lb = lower bounds, ub = upper bounds
't = total elements
DIM AS LONG s_ub, s_lb, s_t
DIM AS LONG d_ub, d_lb, d_t
DIM AS LONG n_lb, n_ub, n_t
DIM AS LONG i, n

s_lb& = LBOUND(source_arr~%%)
s_ub& = UBOUND(source_arr~%%)
d_lb& = LBOUND(dest_arr~%%)
d_ub& = UBOUND(dest_arr~%%)
s_t& = (s_ub& - s_lb&)
d_t& = (d_ub& - d_lb&)
n_t& = s_t& + d_t&
n_lb& = d_lb&
n_ub& = d_ub& + s_t& + 1

REDIM _PRESERVE dest_arr(n_lb& TO n_ub&) AS _UNSIGNED _BYTE
FOR i& = s_lb& TO s_ub&
n& = d_ub& + 1 + i& - s_lb&
dest_arr~%%(n&) = source_arr~%%(i&)
NEXT i&
END SUB
Loading

0 comments on commit 9b6bed1

Please sign in to comment.