public Element < T > getElement ( int index , boolean fromFront ) { if ( index > size || index < 0 ) { throw new IllegalArgumentException ( "index is out of bounds" ) ; } if ( fromFront ) { Element < T > e = first ; for ( int i = 0 ; i < index ; i ++ ) { e = e . next ; } return e ; } else { Element < T > e = last ; for ( int i = 0 ; i < index ; i ++ ) { e = e . previous ; } return e ; } }
Returns the N th element when counting from the from or from the back