key = _evictionKeyCursor._lastReturned.value();
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); _size = 0; _modCount = 0; _cursors = new ArrayList<WeakReference<Cursor>>(); _head = new Listable<E>(null,null,null); int size = in.readInt(); for (int i=0;i<size;i++) { this.add((E)in.readObject()); } }
for(Listable<E> elt = _head.next(), past = null; null != elt && past != _head.prev(); elt = (past = elt).next()) { if (null == elt.value()) { return ndx; for(Listable<E> elt = _head.next(), past = null; null != elt && past != _head.prev(); elt = (past = elt).next()) { if (o.equals(elt.value())) { return ndx;
CursorableSubList(CursorableLinkedList list, int from, int to) { if(0 > from || list.size() < to) { throw new IndexOutOfBoundsException(); } else if(from > to) { throw new IllegalArgumentException(); } _list = list; if(from < list.size()) { _head.setNext(_list.getListableAt(from)); _pre = (null == _head.next()) ? null : _head.next().prev(); } else { _pre = _list.getListableAt(from-1); } if(from == to) { _head.setNext(null); _head.setPrev(null); if(to < list.size()) { _post = _list.getListableAt(to); } else { _post = null; } } else { _head.setPrev(_list.getListableAt(to-1)); _post = _head.prev().next(); } _size = to - from; _modCount = _list._modCount; }
/** * 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 org.apache.commons.collections.CursorableLinkedList.Listable} */ protected Listable insertListable(Listable before, Listable after, Object value) { _modCount++; _size++; Listable elt = new Listable(before,after,value); if(null != before) { before.setNext(elt); } else { _head.setNext(elt); } if(null != after) { after.setPrev(elt); } else { _head.setPrev(elt); } broadcastListableInserted(elt); return 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 org.apache.commons.collections.CursorableLinkedList.Listable} */ protected Listable<E> insertListable(Listable<E> before, Listable<E> after, E value) { _modCount++; _size++; Listable<E> elt = new Listable<E>(before,after,value); if(null != before) { before.setNext(elt); } else { _head.setNext(elt); } if(null != after) { after.setPrev(elt); } else { _head.setPrev(elt); } broadcastListableInserted(elt); return 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 org.apache.commons.collections.CursorableLinkedList.Listable} */ protected Listable insertListable(Listable before, Listable after, Object value) { _modCount++; _size++; Listable elt = new Listable(before,after,value); if(null != before) { before.setNext(elt); } else { _head.setNext(elt); } if(null != after) { after.setPrev(elt); } else { _head.setPrev(elt); } broadcastListableInserted(elt); return 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; }
CursorableSubList(CursorableLinkedList<E> list, int from, int to) { if(0 > from || list.size() < to) { throw new IndexOutOfBoundsException(); } else if(from > to) { throw new IllegalArgumentException(); } _list = list; if(from < list.size()) { _head.setNext(_list.getListableAt(from)); _pre = (null == _head.next()) ? null : _head.next().prev(); } else { _pre = _list.getListableAt(from-1); } if(from == to) { _head.setNext(null); _head.setPrev(null); if(to < list.size()) { _post = _list.getListableAt(to); } else { _post = null; } } else { _head.setPrev(_list.getListableAt(to-1)); _post = _head.prev().next(); } _size = to - from; _modCount = _list._modCount; }
/** * 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; }
/** * 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; }
/** * 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 org.apache.commons.collections.CursorableLinkedList.Listable} */ protected Listable<E> insertListable(Listable<E> before, Listable<E> after, E value) { _modCount++; _size++; Listable<E> elt = new Listable<E>(before,after,value); if(null != before) { before.setNext(elt); } else { _head.setNext(elt); } if(null != after) { after.setPrev(elt); } else { _head.setPrev(elt); } broadcastListableInserted(elt); return elt; }
/** * Replaces the element at the specified position in this list with the * specified element. * * @param index index of element to replace. * @param element element to be stored at the specified position. * @return the element previously at the specified position. * * @throws ClassCastException if the class of the specified element * prevents it from being added to this list. * @throws IllegalArgumentException if some aspect of the specified * element prevents it from being added to this list. * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index >= size()). */ public E set(int index, E element) { Listable<E> elt = getListableAt(index); E val = elt.setValue(element); broadcastListableChanged(elt); return val; }
/** * Removes the given * {@link org.apache.commons.collections.CursorableLinkedList.Listable} * from my list. */ protected void removeListable(Listable<E> elt) { _modCount++; _size--; if(_head.next() == elt) { _head.setNext(elt.next()); } if(null != elt.next()) { elt.next().setPrev(elt.prev()); } if(_head.prev() == elt) { _head.setPrev(elt.prev()); } if(null != elt.prev()) { elt.prev().setNext(elt.next()); } broadcastListableRemoved(elt); }
/** * Replaces the element at the specified position in this list with the * specified element. * * @param index index of element to replace. * @param element element to be stored at the specified position. * @return the element previously at the specified position. * * @throws ClassCastException if the class of the specified element * prevents it from being added to this list. * @throws IllegalArgumentException if some aspect of the specified * element prevents it from being added to this list. * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index >= size()). */ public Object set(int index, Object element) { Listable elt = getListableAt(index); Object val = elt.setValue(element); broadcastListableChanged(elt); return val; }
/** * Replaces the element at the specified position in this list with the * specified element. * * @param index index of element to replace. * @param element element to be stored at the specified position. * @return the element previously at the specified position. * * @throws ClassCastException if the class of the specified element * prevents it from being added to this list. * @throws IllegalArgumentException if some aspect of the specified * element prevents it from being added to this list. * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index >= size()). */ public E set(int index, E element) { Listable<E> elt = getListableAt(index); E val = elt.setValue(element); broadcastListableChanged(elt); return val; }
/** * Removes the given * {@link org.apache.commons.collections.CursorableLinkedList.Listable} * from my list. */ protected void removeListable(Listable elt) { _modCount++; _size--; if(_head.next() == elt) { _head.setNext(elt.next()); } if(null != elt.next()) { elt.next().setPrev(elt.prev()); } if(_head.prev() == elt) { _head.setPrev(elt.prev()); } if(null != elt.prev()) { elt.prev().setNext(elt.next()); } 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 org.apache.commons.collections.CursorableLinkedList.Listable} * from my list. */ protected void removeListable(Listable<E> elt) { _modCount++; _size--; if(_head.next() == elt) { _head.setNext(elt.next()); } if(null != elt.next()) { elt.next().setPrev(elt.prev()); } if(_head.prev() == elt) { _head.setPrev(elt.prev()); } if(null != elt.prev()) { elt.prev().setNext(elt.next()); } broadcastListableRemoved(elt); }
/** * Replaces the element at the specified position in this list with the * specified element. * * @param index index of element to replace. * @param element element to be stored at the specified position. * @return the element previously at the specified position. * * @throws ClassCastException if the class of the specified element * prevents it from being added to this list. * @throws IllegalArgumentException if some aspect of the specified * element prevents it from being added to this list. * @throws IndexOutOfBoundsException if the index is out of range * (index < 0 || index >= size()). */ public Object set(int index, Object element) { Listable elt = getListableAt(index); Object val = elt.setValue(element); broadcastListableChanged(elt); return val; }