Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Array_Insert_Sorted(arrBottom /*Address*/, arrMid /*Values->*/, arrTop, value) {
- // Is array full?
- if (arrMid == arrTop) {
- return false
- }
- // Create our local vars
- let insert = value, i = 0
- // Loop through array
- for (; i < arrMid; i++) {
- // If index is > our inserrt value, swap
- if (arrBottom[i/* << 1*/] > insert) {
- let temp = arrBottom[i/* << 1*/]
- arrBottom[i] = insert
- insert = temp
- }
- }
- // Finally, add to end of array
- arrBottom[i] = insert
- // Return true if add was successful
- return true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement