/** * Returns a fail-fast sublist. * @see List#subList(int,int) */ public List<E> subList(int i, int j) { if(i < 0 || j > _size || i > j) { throw new IndexOutOfBoundsException(); } else if(i == 0 && j == _size) { return this; } else { return new CursorableSubList<E>(this,i,j); } }
@Override public <T> T[] toArray(T a[]) { checkForComod(); return super.toArray(a); }
@Override public void clear() { checkForComod(); Iterator<E> it = iterator(); while(it.hasNext()) { it.next(); it.remove(); } }
/** * Removes the given {@link CursorableLinkedList.Listable} from my list. */ @Override protected void removeListable(Listable<E> elt) { _modCount++; _size--; if(_head.next() == elt && _head.prev() == elt) { _head.setNext(null); _head.setPrev(null); } if(_head.next() == elt) { _head.setNext(elt.next()); } if(_head.prev() == elt) { _head.setPrev(elt.prev()); } _list.removeListable(elt); broadcastListableRemoved(elt); }
/** * Inserts a new <i>value</i> into my * list, after the specified <i>before</i> element, and before the * specified <i>after</i> element * * @return the newly created {@link CursorableLinkedList.Listable} */ @Override protected Listable<E> insertListable(Listable<E> before, Listable<E> after, E value) { _modCount++; _size++; Listable<E> elt = _list.insertListable((null == before ? _pre : before), (null == after ? _post : after),value); if(null == _head.next()) { _head.setNext(elt); _head.setPrev(elt); } if(before == _head.prev()) { _head.setPrev(elt); } if(after == _head.next()) { _head.setNext(elt); } broadcastListableInserted(elt); return elt; }
/** * Removes the given {@link CursorableLinkedList.Listable} from my list. */ protected void removeListable(Listable elt) { _modCount++; _size--; if(_head.next() == elt && _head.prev() == elt) { _head.setNext(null); _head.setPrev(null); } if(_head.next() == elt) { _head.setNext(elt.next()); } if(_head.prev() == elt) { _head.setPrev(elt.prev()); } _list.removeListable(elt); broadcastListableRemoved(elt); }
/** * Inserts a new <i>value</i> into my * list, after the specified <i>before</i> element, and before the * specified <i>after</i> element * * @return the newly created {@link CursorableLinkedList.Listable} */ @Override protected Listable<E> insertListable(Listable<E> before, Listable<E> after, E value) { _modCount++; _size++; Listable<E> elt = _list.insertListable((null == before ? _pre : before), (null == after ? _post : after),value); if(null == _head.next()) { _head.setNext(elt); _head.setPrev(elt); } if(before == _head.prev()) { _head.setPrev(elt); } if(after == _head.next()) { _head.setNext(elt); } broadcastListableInserted(elt); return elt; }
@Override public boolean addAll(Collection<? extends E> c) { checkForComod(); return super.addAll(c); }
@Override public void clear() { checkForComod(); Iterator<E> it = iterator(); while(it.hasNext()) { it.next(); it.remove(); } }
/** * Returns a fail-fast sublist. * @see List#subList(int,int) */ public List<E> subList(int i, int j) { if(i < 0 || j > _size || i > j) { throw new IndexOutOfBoundsException(); } else if(i == 0 && j == _size) { return this; } else { return new CursorableSubList<E>(this,i,j); } }
/** * Removes the given {@link CursorableLinkedList.Listable} from my list. */ protected void removeListable(Listable elt) { _modCount++; _size--; if(_head.next() == elt && _head.prev() == elt) { _head.setNext(null); _head.setPrev(null); } if(_head.next() == elt) { _head.setNext(elt.next()); } if(_head.prev() == elt) { _head.setPrev(elt.prev()); } _list.removeListable(elt); broadcastListableRemoved(elt); }
/** * Inserts a new <i>value</i> into my * list, after the specified <i>before</i> element, and before the * specified <i>after</i> element * * @return the newly created {@link CursorableLinkedList.Listable} */ protected Listable insertListable(Listable before, Listable after, Object value) { _modCount++; _size++; Listable elt = _list.insertListable((null == before ? _pre : before), (null == after ? _post : after),value); if(null == _head.next()) { _head.setNext(elt); _head.setPrev(elt); } if(before == _head.prev()) { _head.setPrev(elt); } if(after == _head.next()) { _head.setNext(elt); } broadcastListableInserted(elt); return elt; }
@Override public boolean add(E o) { checkForComod(); return super.add(o); }
@Override public void clear() { checkForComod(); Iterator<E> it = iterator(); while(it.hasNext()) { it.next(); it.remove(); } }
/** * Returns a fail-fast sublist. * @see List#subList(int,int) */ public List subList(int i, int j) { if(i < 0 || j > _size || i > j) { throw new IndexOutOfBoundsException(); } else if(i == 0 && j == _size) { return this; } else { return new CursorableSubList(this,i,j); } }
/** * Removes the given {@link CursorableLinkedList.Listable} from my list. */ @Override protected void removeListable(Listable<E> elt) { _modCount++; _size--; if(_head.next() == elt && _head.prev() == elt) { _head.setNext(null); _head.setPrev(null); } if(_head.next() == elt) { _head.setNext(elt.next()); } if(_head.prev() == elt) { _head.setPrev(elt.prev()); } _list.removeListable(elt); broadcastListableRemoved(elt); }
/** * Inserts a new <i>value</i> into my * list, after the specified <i>before</i> element, and before the * specified <i>after</i> element * * @return the newly created {@link CursorableLinkedList.Listable} */ protected Listable insertListable(Listable before, Listable after, Object value) { _modCount++; _size++; Listable elt = _list.insertListable((null == before ? _pre : before), (null == after ? _post : after),value); if(null == _head.next()) { _head.setNext(elt); _head.setPrev(elt); } if(before == _head.prev()) { _head.setPrev(elt); } if(after == _head.next()) { _head.setNext(elt); } broadcastListableInserted(elt); return elt; }
@Override public boolean addFirst(E o) { checkForComod(); return super.addFirst(o); }
public void clear() { checkForComod(); Iterator it = iterator(); while(it.hasNext()) { it.next(); it.remove(); } }
/** * Returns a fail-fast sublist. * @see List#subList(int,int) */ public List<E> subList(int i, int j) { if(i < 0 || j > _size || i > j) { throw new IndexOutOfBoundsException(); } else if(i == 0 && j == _size) { return this; } else { return new CursorableSubList<E>(this,i,j); } }