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

Online Help

All Products    Maple    MapleSim


Set.toArray

convert Set to array

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Object[] toArray()

T[] toArray( T[] a )

Parameters

a

-

array

Description

• 

The toArray function returns an array corresponding to the elements of the Set.

• 

When invoked with no arguments, toArray returns an array of type Object populated with elements of the Set.

• 

When invoked with an array argument, toArray returns an array populated with the elements of the Set. The runtime type T of this array matches that of the input array a.

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 );

        Set s = (Set)engine.evaluate( "{2,5,8,11};" );

        Object[] arr = s.toArray();

        for (int i = 0; i < arr.length, i++)

            System.out.println( "Element " + i + ": " + arr[i] );

        }

        Algebraic[] algArray_in = new Algebraic[1];

        Algebraic[] algArray_out = s.toArray( algArray_in );

    }

}

Executing this code produces the following output:

Element 0: 2

Element 1: 5

Element 2: 8

Element 3: 11

See Also

ExternalCalling/Java/MapleException

OpenMaple

OpenMaple/Java/Algebraic

OpenMaple/Java/API

OpenMaple/Java/Set

OpenMaple/Java/Set/contains

OpenMaple/Java/Set/containsAll

OpenMaple/Java/Set/iterator

OpenMaple/Java/Set/select