Skip to content

Instantly share code, notes, and snippets.

@gunnarig
Created February 4, 2019 11:42
Show Gist options
  • Save gunnarig/c2529559cb6f91414fb15d99758ff092 to your computer and use it in GitHub Desktop.
Save gunnarig/c2529559cb6f91414fb15d99758ff092 to your computer and use it in GitHub Desktop.
def insert(self, value, index):
if self.__capacity == self.__size:
self.__size * self.__capacity
return ArrayList.insert(self,value,index)
elif self.__capacity >= self.__size:
count = 1
while index >= count:
if count != index:
self.__arr[self.__size+1-count] = self.__arr[self.__size-count]
count += 1
elif count == index:
self.__arr[index-1] = value
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment