containsKey - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Table.containsKey

check if a key is associated with an element in the Table

Table.containsValue

check if a value is associated with an element in the Table

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

boolean containsKey( Algebraic key )

boolean containsValue( Algebraic value )

Parameters

key

-

index to check

Description

• 

The containsKey function returns true if the Algebraic object key is associated with an element in the Table.  If key is not used, false is returned.

• 

The containsValue function returns true if the Algebraic object value is associated with a value (entry) in the Table.  Otherwise false is returned.

• 

The containsKey function is identical to has except that it does not throw a MapleException. Similarly, containsValue function is identical to member except that it does not throw a MapleException.

Examples

import com.maplesoft.openmaple.*;

import com.maplesoft.externalcall.MapleException;

class Example

{

    public static void main( String notused[] ) throws MapleException

    {

        String[] mapleArgs = { "java" };

        Engine engine = new Engine( mapleArgs, new EngineCallBacksDefault(), null, null );

        Table t = (Table)engine.evaluate( "table([1=100,2=200,3=300,4=400]):" );

        System.out.println( t.containsKey( engine.newNumeric( 1 ) ) );

        System.out.println( t.containsKey( engine.newNumeric( 2 ) ) );

        System.out.println( t.containsKey( engine.newNumeric( 5 ) ) );

        System.out.println( t.containsKey( engine.newNumeric( 6 ) ) );

        System.out.println( t.containsValue( engine.newNumeric( 100 ) ) );

        System.out.println( t.containsValue( engine.newNumeric( 200 ) ) );

        System.out.println( t.containsValue( engine.newNumeric( 500 ) ) );

        System.out.println( t.containsValue( engine.newNumeric( 600 ) ) );

    }

}

Executing this code produces the following output.

true

true

false

false

true

true

false

false

See Also

ExternalCalling/Java/MapleException

OpenMaple

OpenMaple/Java/Algebraic

OpenMaple/Java/API

OpenMaple/Java/Table

OpenMaple/Java/Table/assign

OpenMaple/Java/Table/remove

OpenMaple/Java/Table/select