/** * Returns the element at the end of this list. */ public Object getLast() { try { return _head.prev().value(); } catch(NullPointerException e) { throw new NoSuchElementException(); } }
/** * Returns the element at the end of this list. */ public Object getLast() { try { return _head.prev().value(); } catch(NullPointerException e) { throw new NoSuchElementException(); } }
public void add(Object o) { checkForComod(); _cur.setPrev(insertListable(_cur.prev(),_cur.next(),o)); _lastReturned = null; _nextIndex++; _expectedModCount++; }
/** * Appends the specified element to the end of this list. * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean add(Object o) { insertListable(_head.prev(),null,o); return true; }
public void add(Object o) { checkForComod(); Listable elt = insertListable(_cur.prev(),_cur.next(),o); _cur.setPrev(elt); _cur.setNext(elt.next()); _lastReturned = null; _nextIndex++; _expectedModCount++; }
/** * Returns an array containing all of the elements in this list in proper * sequence. Obeys the general contract of the {@link Collection#toArray} method. * * @return an array containing all of the elements in this list in proper * sequence. */ public Object[] toArray() { Object[] array = new Object[_size]; int i = 0; for(Listable elt = _head.next(), past = null; null != elt && past != _head.prev(); elt = (past = elt).next()) { array[i++] = elt.value(); } return array; }
public boolean hasPrevious() { checkForComod(); return(null != _cur.prev() && _cur.next() != _head.next()); }
public void remove() { checkForComod(); if(null == _lastReturned) { throw new IllegalStateException(); } else { _cur.setNext(_lastReturned == _head.prev() ? null : _lastReturned.next()); _cur.setPrev(_lastReturned == _head.next() ? null : _lastReturned.prev()); removeListable(_lastReturned); _lastReturned = null; _nextIndex--; _expectedModCount++; } }
ListIter(int index) { if(index == 0) { _cur = new Listable(null,_head.next(),null); _nextIndex = 0; } else if(index == _size) { _cur = new Listable(_head.prev(),null,null); _nextIndex = _size; } else { Listable temp = getListableAt(index); _cur = new Listable(temp.prev(),temp,null); _nextIndex = index; } }
/** * Appends the specified element to the end of this list. * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean add(Object o) { insertListable(_head.prev(),null,o); return true; }
public void add(Object o) { checkForComod(); Listable elt = insertListable(_cur.prev(),_cur.next(),o); _cur.setPrev(elt); _cur.setNext(elt.next()); _lastReturned = null; _nextIndex++; _expectedModCount++; }
public void add(Object o) { checkForComod(); _cur.setPrev(insertListable(_cur.prev(),_cur.next(),o)); _lastReturned = null; _nextIndex++; _expectedModCount++; }
/** * Inserts the specified element at the end of this list. * (Equivalent to {@link #add(java.lang.Object)}). * * @param o element to be appended to this list. * @return <tt>true</tt> */ public boolean addLast(Object o) { insertListable(_head.prev(),null,o); return true; }