All Packages Class Hierarchy Previous Next Index
Functions 1 - No description available.
Functions 2 - No description available.
Functions 3 - No description available.
Functions 4 - No description available.
Functions 5 - No description available.
Functions 6 - No description available.
Functions 7 - No description available.
Functions 8 - No description available.
Functions1 Example Code
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
public class Functions1
{
public static void main( String[] args )
{
Array array = new Array();
array.add( new Integer( 3 ) );
array.add( new Integer( -2 ) );
array.add( new Integer( 3 ) );
array.add( new Integer( -5 ) );
array.add( new Integer( -4 ) );
UnaryPredicate predicate = new PositiveNumber();
int n = Counting.countIf( array, predicate );
System.out.println( "Number of positive Integers in " + array + " = " + n );
}
}
Number of positive Integers in Array( 3, -2, 3, -5, -4 ) = 2
Functions2 Example Code
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
public class Functions2
{
public static void main( String[] args )
{
boolean array[] = { false, false, true, false, true };
BooleanArray bools = new BooleanArray( array );
UnaryPredicate predicate = new LogicalNot();
int n = Counting.countIf( bools, predicate );
System.out.println( "Number of false in " + bools + " = " + n );
}
}
Number of false in boolean[]( false, false, true, false, true ) = 3
Functions3 Example Code
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
public class Functions3
{
public static void main( String[] args )
{
Deque deque = new Deque();
deque.add( "cat" );
deque.add( "ape" );
deque.add( "dog" );
deque.add( "bat" );
System.out.println( "unsorted = " + deque );
BinaryPredicate comparator = new GreaterString();
Sorting.sort( deque, comparator );
System.out.println( "sorted = " + deque );
}
}
unsorted = Deque( cat, ape, dog, bat )
sorted = Deque( dog, cat, bat, ape )
Functions4 Example Code
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
public class Functions4
{
public static void main( String[] args )
{
long array[] = { 3, 1, 5, -2, 7, 9 };
LongArray longArray = new LongArray( array );
BinaryPredicate comparator = new LessNumber( new Long( 0 ).getClass() );
System.out.println( "unsorted = " + longArray );
Sorting.sort( longArray, comparator );
System.out.println( "sorted = " + longArray );
}
}
unsorted = long[]( 3, 1, 5, -2, 7, 9 )
sorted = long[]( -2, 1, 3, 5, 7, 9 )
Functions5 Example Code
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
public class Functions5
{
public static void main( String[] args )
{
Deque deque = new Deque();
deque.add( new Integer( 4 ) );
deque.add( new Integer( -2 ) );
deque.add( new Integer( 3 ) );
UnaryFunction function = new NegateNumber();
System.out.println( "before = " + deque );
Transforming.transform( deque, deque.begin(), function );
System.out.println( "after = " + deque );
}
}
before = Deque( 4, -2, 3 )
after = Deque( -4, 2, -3 )
Functions6 Example Code
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
public class Functions6
{
public static void main( String[] args )
{
DList list = new DList();
list.add( "dog" );
list.add( "ape" );
list.add( "emu" );
UnaryPredicate predicate = new BindSecondPredicate( new GreaterString(), "bat" );
int n = Counting.countIf( list, predicate );
System.out.println( "The number of strings in " + list + " > bat = " + n );
}
}
The number of strings in DList( dog, ape, emu ) > bat = 2
Functions7 Example Code
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
public class Functions7
{
public static void main( String[] args )
{
Array array = new Array();
array.add( "ape" );
array.add( "giraffe" );
array.add( "lizard" );
BinaryPredicate comparator = new BinaryComposePredicate( new GreaterNumber(), new LengthString(), new LengthString() );
System.out.println( "before = " + array );
Sorting.sort( array, comparator );
System.out.println( "after = " + array );
}
}
before = Array( ape, giraffe, lizard )
after = Array( giraffe, lizard, ape )
Functions8 Example Code
// Copyright(c) 1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
public class Functions8
{
public static void main( String[] args )
{
double array[] = { 3, 1, 5, -2, 7, 9 };
DoubleArray doubleArray = new DoubleArray( array );
BinaryPredicate comparator = new LessNumber( new Double( 0 ).getClass() );
System.out.println( "unsorted = " + doubleArray );
Sorting.sort( doubleArray, comparator );
System.out.println( "sorted = " + doubleArray );
}
}
unsorted = double[]( 3.0, 1.0, 5.0, -2.0, 7.0, 9.0 )
sorted = double[]( -2.0, 1.0, 3.0, 5.0, 7.0, 9.0 )
All Packages Class Hierarchy Previous Next Index