Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. function Array_Insert_Sorted(arrBottom /*Address*/, arrMid /*Values->*/, arrTop, value) {
  2. // Is array full?
  3. if (arrMid == arrTop) {
  4. return false
  5. }
  6. // Create our local vars
  7. let insert = value, i = 0
  8.  
  9. // Loop through array
  10. for (; i < arrMid; i++) {
  11. // If index is > our inserrt value, swap
  12. if (arrBottom[i/* << 1*/] > insert) {
  13. let temp = arrBottom[i/* << 1*/]
  14. arrBottom[i] = insert
  15. insert = temp
  16. }
  17. }
  18. // Finally, add to end of array
  19. arrBottom[i] = insert
  20. // Return true if add was successful
  21. return true
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement