home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
jbuilder
/
jsamples.z
/
Algorithms3.java
< prev
next >
Wrap
Text File
|
1997-07-30
|
884b
|
32 lines
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
/**
* Counting provides algorithms for tabulating the elements of a container.
*
* @see COM.objectspace.jgl.Counting
* @version 2.0.2
* @author ObjectSpace, Inc.
*/
public class Algorithms3
{
public static void main( String[] args )
{
SList list = new SList();
list.add( new Integer( -1 ) );
list.add( new Integer( 1 ) );
list.add( new Integer( -2 ) );
list.add( new Integer( 1 ) );
list.add( new Integer( -3 ) );
System.out.println( "list = " + list );
Object value = new Integer( 1 );
int n1 = Counting.count( list, value );
System.out.println( "Occurences of " + value + " = " + n1 );
int n2 = Counting.countIf( list, new NegativeNumber() );
System.out.println( "Occurences of a negative = " + n2 );
}
}