Last active
August 29, 2015 14:08
-
-
Save bluepnume/ca40df02fa4420284c3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Insert an element | |
| // data = array | |
| // currentSize = current size of array (??) | |
| // newElement = the element to insert | |
| // pos = the position to insert it | |
| // If the array is bigger than currentSize (??) | |
| if (currentSize < data.length) | |
| { | |
| // Loop down from currentSize to pos+1 | |
| for (int i = currentSize; i > pos; i--) | |
| { | |
| // Move the element up an index | |
| data[i] = data[i - 1]; | |
| } | |
| // Insert the new index at pos | |
| data[pos] = newElement; | |
| // Update our current size | |
| currentSize++; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment