home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / examples / slist6.java < prev    next >
Encoding:
Java Source  |  1996-09-10  |  861 b   |  35 lines

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2.  
  3. import jgl.*;
  4.  
  5. /**
  6.  * Splicing a piece of a SList into another.
  7.  * <p>
  8.  * @see jgl.Vector
  9.  * @version 1.1
  10.  * @author ObjectSpace, Inc.
  11.  */
  12.  
  13. public class SList6
  14.   {
  15.   public static void main( String[] args )
  16.     {
  17.     SList list1 = new SList();
  18.     list1.add( "apple" );
  19.     list1.add( "banana" );
  20.     SList list2 = new SList();  
  21.     list2.add( "lotus" );
  22.     list2.add( "ferrari" );
  23.     list2.add( "lamborghini" );
  24.     System.out.println( "before: list1 = " + list1 + ", list2 = " + list2 );
  25.  
  26.     SListIterator i = list1.begin();
  27.     i.advance();
  28.     SListIterator start = list2.begin();
  29.     SListIterator finish = list2.begin();
  30.     finish.advance( 2 );
  31.     list1.splice( i, list2, start, finish );
  32.     System.out.println( "after: list1 = " + list1 + ", list2 = " + list2 );
  33.     }
  34.   }
  35.