Table.put - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : OpenMaple : Java Application Programming Interface : Table Class : OpenMaple/Java/Table/put

Table.put

add entry to table

Table.putAll

add collection to table

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Algebraic put( Algebraic key, Algebraic value )

void putAll( Map<? extends Algebraic, ? extends Algebraic> m )

Parameters

key

-

index of the element to access

value

-

value to add to table

m

-

java.util.Map

Description

• 

The put function associates the Algebraic object val with the Algebraic index key in the Table. If a value is already assigned to the index key, it is overwritten by val.

• 

The putAll function adds the map m into the Table in its entirety.

• 

The put function is identical to assign 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]);" );

        t.put( engine.newName( "a" ), engine.newNumeric( 2 ) );

        t.put( engine.newName( "b" ), engine.newNumeric( 3 ) );

        for (Algebraic e : t.keySet()) {

            System.out.println( "Key: " + e );

        }

    }

}

Executing this code produces the following output.

1

2

a

b

null

See Also

ExternalCalling/Java/MapleException

OpenMaple

OpenMaple/Java/Algebraic

OpenMaple/Java/API

OpenMaple/Java/Table

OpenMaple/Java/Table/assign

OpenMaple/Java/Table/clear

OpenMaple/Java/Table/has

OpenMaple/Java/Table/keySet

OpenMaple/Java/Table/remove

OpenMaple/Java/Table/unassign

OpenMaple/Java/Table/values