MCPcopy
hub / github.com/wangzheng0822/algo / resize

Method resize

java/05_array/GenericArray.java:143–150  ·  view source on GitHub ↗
(int capacity)

Source from the content-addressed store, hash-verified

141
142 // 扩容方法,时间复杂度 O(n)
143 private void resize(int capacity) {
144 T[] newData = (T[]) new Object[capacity];
145
146 for (int i = 0; i < size; i++) {
147 newData[i] = data[i];
148 }
149 data = newData;
150 }
151
152 private void checkIndex(int index) {
153 if (index < 0 || index >= size) {

Callers 2

addMethod · 0.95
removeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected