Last active
September 16, 2017 21:55
-
-
Save jp26jp/1c40bd51a0fb94c13e042eed9fd4a229 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
/** | |
* We figured out part of the answer to our question. | |
* So now we'd just like to know if we're on the right track. | |
*/ | |
public void insert(int index, E data) | |
{ | |
ensureCapacity(indexCounter + 1); | |
for (int i = elementData.length; i > index; i--) | |
{ | |
int currentIdx = (i + elementData.length - 1) % elementData.length; | |
int nextIdx = (i + 1 + elementData.length - 1) % elementData.length; | |
elementData[nextIdx] = elementData[currentIdx]; | |
System.out.println(elementData[currentIdx] + " moved to index: " + nextIdx); | |
modCounter++; | |
} | |
indexCounter++; | |
setElement(index, data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment