public boolean addAll(Iterable<? extends T> iterable) { boolean modified = false; Iterator<? extends T> e = iterable.iterator(); while (e.hasNext()) { if (add(e.next())) { modified = true; } } sorted = !modified; if (!sorted) { unsetFeature(SORTED); } return modified; }
public boolean addAll(Iterable<? extends T> iterable) { boolean modified = false; Iterator<? extends T> e = iterable.iterator(); while (e.hasNext()) { if (add(e.next())) { modified = true; } } sorted = !modified; if (!sorted) { unsetFeature(SORTED); } return modified; }
public void add(int index, E element) { if (index < 0 || index > size) throw new IndexOutOfBoundsException(); checkForComodification(); l.add(index + offset, element); expectedModCount = l.modCount(); size++; modCount++; }
public void add(int index, E element) { if (index < 0 || index > size) throw new IndexOutOfBoundsException(); checkForComodification(); l.add(index + offset, element); expectedModCount = l.modCount(); size++; modCount++; }
private C.List<T> unLazyPrepend(Enumeration<? extends T> enumeration) { if (isMutable()) { int pos = 0; while (enumeration.hasMoreElements()) { add(pos++, enumeration.nextElement()); } return this; } ListBuilder<T> lb = new ListBuilder<T>(size() * 2); lb.append(enumeration).append(this); return lb.toList(); }
private C.List<T> unLazyPrepend(Iterator<? extends T> iterator) { if (isMutable()) { int pos = 0; while (iterator.hasNext()) { add(pos++, iterator.next()); } return this; } ListBuilder<T> lb = new ListBuilder<T>(size() * 2); lb.append(iterator).append(this); return lb.toList(); }
private C.List<T> unLazyPrepend(Enumeration<? extends T> enumeration) { if (isMutable()) { int pos = 0; while (enumeration.hasMoreElements()) { add(pos++, enumeration.nextElement()); } return this; } ListBuilder<T> lb = new ListBuilder<T>(size() * 2); lb.append(enumeration).append(this); return lb.toList(); }
private C.List<T> unLazyPrepend(Iterator<? extends T> iterator) { if (isMutable()) { int pos = 0; while (iterator.hasNext()) { add(pos++, iterator.next()); } return this; } ListBuilder<T> lb = new ListBuilder<T>(size() * 2); lb.append(iterator).append(this); return lb.toList(); }
private C.List<T> unLazyPrepend(Iterable<? extends T> iterable) { if (isMutable()) { int pos = 0; for (T t : iterable) { add(pos++, t); } return this; } // immutable if (isImmutable()) { ListBuilder<T> lb = new ListBuilder<T>(size() * 2); lb.append(iterable).append(this); return lb.toList(); } // mutable but read only C.List<T> l = C.newSizedList(size() * 2); l.addAll(iterable); l.addAll(this); return l; }
add(index, t); return this;
add(index, t); return this;
@Override public C.List<T> append(T t) { if (isMutable()) { add(t); return this; } // Immutable if (isImmutable()) { ListBuilder<T> lb = new ListBuilder<T>(size() + 1); lb.addAll(this); lb.add(t); return lb.toList(); } // mutable but readonly C.List<T> l = C.newSizedList(size() + 1); l.addAll(this); l.add(t); return l; }
@Override public C.List<T> append(T t) { if (isMutable()) { add(t); return this; } // Immutable if (isImmutable()) { ListBuilder<T> lb = new ListBuilder<T>(size() + 1); lb.addAll(this); lb.add(t); return lb.toList(); } // mutable but readonly C.List<T> l = C.newSizedList(size() + 1); l.addAll(this); l.add(t); return l; }
private C.List<T> unLazyPrepend(Iterable<? extends T> iterable) { if (isMutable()) { int pos = 0; for (T t : iterable) { add(pos++, t); } return this; } // immutable if (isImmutable()) { ListBuilder<T> lb = new ListBuilder<T>(size() * 2); lb.append(iterable).append(this); return lb.toList(); } // mutable but read only C.List<T> l = C.newSizedList(size() * 2); l.addAll(iterable); l.addAll(this); return l; }
/** * {@inheritDoc} * For mutable list, this method will insert the * element at {@code 0} position. */ @Override public C.List<T> prepend(T t) { if (isMutable()) { add(0, t); return this; } // immutable if (isImmutable()) { ListBuilder<T> lb = new ListBuilder<T>(size() + 1); lb.add(t); lb.addAll(this); return lb.toList(); } // readonly but mutable C.List<T> l = C.newSizedList(size() + 1); l.add(t); l.addAll(this); return l; }
/** * {@inheritDoc} * For mutable list, this method will insert the * element at {@code 0} position. */ @Override public C.List<T> prepend(T t) { if (isMutable()) { add(0, t); return this; } // immutable if (isImmutable()) { ListBuilder<T> lb = new ListBuilder<T>(size() + 1); lb.add(t); lb.addAll(this); return lb.toList(); } // readonly but mutable C.List<T> l = C.newSizedList(size() + 1); l.add(t); l.addAll(this); return l; }