home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-07-30 | 1.4 KB | 45 lines |
- // Copyright(c) 1996,1997 ObjectSpace, Inc.
-
- import COM.objectspace.jgl.*;
-
- /**
- * Collapsing consecutive elements in a native array of Objects and an JGL container.
- *
- * @see COM.objectspace.jgl.Filtering
- * @version 2.0.2
- * @author ObjectSpace, Inc.
- */
-
- public class Filtering1
- {
- public static void main( String[] args )
- {
- String[] strings = { "gnu", "emu", "emu", "fox", "fox", "fox", "gnu" };
- ObjectIterator begin = ObjectIterator.begin( strings );
- ObjectIterator end = ObjectIterator.end( strings );
- System.out.print( "strings = " );
- Printing.println( begin, end );
- ObjectIterator last = (ObjectIterator) Filtering.unique( begin, end );
- System.out.print( "filtered strings = " );
- Printing.println( begin, end );
- int remaining = begin.distance( last );
- System.out.println( "remaining = " + remaining );
- System.out.print( "filtered array with bounds given = " );
- end.retreat( remaining );
- Printing.println( begin, end );
-
- Array array = new Array();
- array.add( "gnu" );
- array.add( "emu" );
- array.add( "emu" );
- array.add( "fox" );
- array.add( "fox" );
- array.add( "fox" );
- array.add( "gnu" );
- System.out.println( "array = " + array );
- Deque deque = new Deque();
- Filtering.uniqueCopy( array, new InsertIterator( deque ) );
- System.out.println( "deque = " + deque );
- }
- }
-