⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: ‘Decompress current Excalidraw file’. For more info check in plugin settings under ‘Saving’

Excalidraw Data

Text Elements

size = 3

public void add(E element, int index){ //插入方法需要支持在指定下标位置插入
for (int i = size; i > index; i—) //从后往前,一个一个搬运元素
array[i] = array[i - 1];
array[index] = element; //腾出位置之后,直接插入元素放到对应位置上
size++; //插入完成之后,记得将size自增
}

index=1, i=3

11

22

33

0

1

2

array[3] = array[2];

11

22

0

1

2

33

3

index=1, i=2

array[2] = array[1];

0

1

2

11

33

3

22

array[1] = element;

0

1

2

11

22

33

3

element

size=4