Deque1public class Deque1 extends Object Construction, enumeration, access, pushing, popping. |
Methods Summary |
---|
public static void | main(java.lang.String[] args)
Deque deque = new Deque();
deque.pushBack( "bat" );
deque.add( "cat" );
deque.pushFront( "ape" );
System.out.println( deque );
System.out.println();
System.out.println( "Enumerate the Deque" );
Enumeration e = deque.elements();
while ( e.hasMoreElements() )
System.out.println( e.nextElement() );
System.out.println();
System.out.println( "Iterate through the Deque" );
for ( DequeIterator i = deque.begin(); !i.equals( deque.end() ); i.advance() )
System.out.println( i.get() );
System.out.println();
System.out.println( "Demonstrate access" );
System.out.println( "deque.at( 0 ) = " + deque.at( 0 ) );
System.out.println( "deque.front() = " + deque.front() );
System.out.println( "deque.at( 2 ) = " + deque.at( 2 ) );
System.out.println( "deque.back() = " + deque.back() );
System.out.println();
System.out.println( "Demonstrate modification" );
deque.put( 1, "fox" );
System.out.println( deque );
deque.popFront();
System.out.println( "After popFront() = " + deque );
deque.popBack();
System.out.println( "After popBack() = " + deque );
|
|