ObjectSpace Homepage

JGL - The Generic Collection Library for Java
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Vector examples

Vector1 - Sorting a JDK Vector.


Vector1 Example Code

// Copyright(c) 1996,1997 ObjectSpace, Inc.
import com.objectspace.jgl.adapters.*;
import com.objectspace.jgl.algorithms.*;
import com.objectspace.jgl.predicates.*;
import java.util.Vector;

/**
 * Sorting a JDK Vector.
 *
 * @see java.util.Vector
 * @version 3.0.0
 * @author ObjectSpace, Inc.
 */

public class Vector1
  {
  public static void main( String[] args )
    {
    Vector vector = new Vector();
    vector.addElement( "dog" );
    vector.addElement( "ape" );
    vector.addElement( "bat" );
    System.out.println( "unsorted = " + vector );
    Sorting.sort( VectorIterator.begin( vector ), VectorIterator.end( vector ), new LessString() );
    System.out.println( "sorted = " + vector );
    }
  }

Vector1 Example Output

unsorted = [dog, ape, bat]
sorted = [ape, bat, dog]

All Packages  Class Hierarchy  This Package  Previous  Next  Index