MCPcopy Create free account
hub / github.com/ReadyTalk/avian / delete

Method delete

classpath/java/lang/StringBuilder.java:180–224  ·  view source on GitHub ↗
(int start, int end)

Source from the content-addressed store, hash-verified

178 }
179
180 public StringBuilder delete(int start, int end) {
181 if (start >= end) {
182 return this;
183 }
184
185 if (start < 0 || end > length) {
186 throw new IndexOutOfBoundsException();
187 }
188
189 flush();
190
191 int index = length;
192 Cell p = null;
193 for (Cell c = chain; c != null; c = c.next) {
194 int e = index;
195 int s = index - c.value.length();
196 index = s;
197
198 if (end >= e) {
199 if (start <= s) {
200 if (p == null) {
201 chain = c.next;
202 } else {
203 p.next = c.next;
204 }
205 } else {
206 c.value = c.value.substring(0, start - s);
207 break;
208 }
209 } else {
210 if (start <= s) {
211 c.value = c.value.substring(end - s, e - s);
212 } else {
213 String v = c.value;
214 c.value = v.substring(end - s, e - s);
215 c.next = new Cell(v.substring(0, start - s), c.next);
216 break;
217 }
218 }
219 }
220
221 length -= (end - start);
222
223 return this;
224 }
225
226 public StringBuilder deleteCharAt(int i) {
227 return delete(i, i + 1);

Callers 2

deleteCharAtMethod · 0.95
replaceMethod · 0.95

Calls 4

flushMethod · 0.95
substringMethod · 0.95
lengthMethod · 0.65
substringMethod · 0.45

Tested by

no test coverage detected