if (0 > i || i > length) {
throw new IllegalArgumentException("illegal list index: " + i);
}
List<ATerm> buffer = new ArrayList<ATerm>(i);
ATermList cur = this;
for (lcv = 0; lcv < i; lcv++) {
buffer.add(cur.getFirst());
cur = cur.getNext();
}
/* Skip the old element */
cur = cur.getNext();
/* Add the new element */
cur = cur.insert(el);
/* Add the prefix */
for (--lcv; lcv >= 0; lcv--) {
cur = cur.insert(buffer.get(lcv));
}
return cur;
}