Java Reference
In-Depth Information
public
public T get ( int
int where ) {
TNode < T > t = first ;
int
int i = 0 ;
// If we get to the end of list before 'where', error out
while
while ( i <= where ) {
i ++;
iif (( t = t . next ) == null
null ) {
throw
throw new
new IndexOutOfBoundsException ();
}
}
return
return t . data ;
}
public
public T set ( int
int i , T o ) {
return
return null
null ;
}
public
public boolean
boolean contains ( Object o ) {
TNode < T > t = first ;
while
while (( t = t . next ) != null
null ) {
iif ( t . data . equals ( o )) {
return
return true
true ;
}
}
return
return false
false ;
}
public
public boolean
boolean addAll ( Collection <? extends
extends T > c ) {
c . forEach ( o -> add (( T ) o ));
return
return false
false ;
}
public
public ListIterator < T > listIterator () {
throw
throw new
new UnsupportedOperationException ( "listIterator" );
}
public
public Iterator < T > iterator () {
return
return new
new Iterator < T >() {
TNode < T > t = first . next ;
public
public boolean
boolean hasNext () {
return
return t != last ;
}
public
public T next () {
iif ( t == last )
throw
throw new
new IndexOutOfBoundsException ();
return
return ( T ) ( t = t . next );
}
Search WWH ::




Custom Search