package LinkedListDoublyJava;
public class LinkedListDoubly {
public LinkedListDoubly( ) {
header = new ListNode( null );
}
public boolean isEmpty( ) {
return header.next == null;
}
public void makeEmpty( ) {
header.next = null;
}
public LinkedListIterator zeroth( ) {
return new LinkedListIterator( header );
}
public LinkedListIterator first( ) {
return new LinkedListIterator( header.next );
}
public void insert( Object x, LinkedListIterator p ) {
if( p != null && p.current != null )
p.current.next = new ListNode( x, p.current.next );
}
public LinkedListIterator find( Object x ) {
ListNode itr = header.next;
while( itr != null && !itr.element.equals( x ) )
itr = itr.next;
return new LinkedListIterator( itr );
}
Tidak ada komentar:
Posting Komentar