MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / add

Method add

Ports/CLDC11/src/java/util/ArrayList.java:109–141  ·  view source on GitHub ↗
(int location, E object)

Source from the content-addressed store, hash-verified

107 ///
108 /// - `IndexOutOfBoundsException`: when `location size()`
109 @Override
110 public void add(int location, E object) {
111 if (location < 0 || location > size) {
112 throw new IndexOutOfBoundsException("" + location + " out of: " + size);
113 }
114 if (location == 0) {
115 if (firstIndex == 0) {
116 growAtFront(1);
117 }
118 array[--firstIndex] = object;
119 } else if (location == size) {
120 if (firstIndex + size == array.length) {
121 growAtEnd(1);
122 }
123 array[firstIndex + size] = object;
124 } else { // must be case: (0 < location && location < size)
125 if (size == array.length) {
126 growForInsert(location, 1);
127 } else if (firstIndex + size == array.length
128 || (firstIndex > 0 && location < size / 2)) {
129 System.arraycopy(array, firstIndex, array, --firstIndex,
130 location);
131 } else {
132 int index = location + firstIndex;
133 System.arraycopy(array, index, array, index + 1, size
134 - location);
135 }
136 array[location + firstIndex] = object;
137 }
138
139 size++;
140 modCount++;
141 }
142
143 /// Adds the specified object at the end of this `ArrayList`.
144 ///

Callers 15

enumerateCamerasMethod · 0.95
splitCharMethod · 0.95
codecsMethod · 0.95
getAllContactsMethod · 0.95
cleanupMethod · 0.95
createImageMethod · 0.95
listFilesMethod · 0.95
getHeaderFieldNamesMethod · 0.95
getHeaderFieldsMethod · 0.95
getAvailableEncodersMethod · 0.95
getAvailableDecodersMethod · 0.95

Calls 4

growAtFrontMethod · 0.95
growAtEndMethod · 0.95
growForInsertMethod · 0.95
arraycopyMethod · 0.95

Tested by 1

getPathToComponentMethod · 0.76